-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathHomeController.cs
37 lines (35 loc) · 1.04 KB
/
HomeController.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using DevExpress.Web;
using DevExpress.Web.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using T983248_MVC.Models;
namespace T983248_MVC.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
return View(new UserModel());
}
[HttpPost]
public ActionResult Index(UserModel modelDTO)
{
string fileName = string.Empty;
if (ModelState.IsValid)
{
if (modelDTO.Attachment.Length > 0 && modelDTO.Attachment[0].ContentLength > 0)
{
fileName = string.Format("~/Content/Files/{0}", modelDTO.Attachment[0].FileName);
modelDTO.Attachment[0].SaveAs(Server.MapPath(fileName));
}
}
SavedModel model = new SavedModel();
model.UserName = modelDTO.UserName;
model.FileUrl = fileName;
return View("Complete", model);
}
}
}