public ActionResult Upload(FormCollection FileDetails, HttpPostedFileBase files) { try { FileEntity fileObj = new FileEntity(); if (FileDetails != null && FileDetails.Count != 0) { fileObj.Name = FileDetails["Name"].ToString(); fileObj.Description = FileDetails["Description"].ToString(); fileObj.Key = FileDetails["key"].ToString(); fileObj.Document = FileDetails["Name"].ToString(); fileObj.File = files; fileObj.UserId = USerConfig.GetUserID(); } if (fileObj.File != null) { if (fileObj.File.ContentLength > 0) { var fileName = Path.GetFileName(fileObj.File.FileName); var path = Path.Combine(Server.MapPath("~/img"), fileName); fileObj.File.SaveAs(path); fileObj.Document = fileName; } } FileBusinessLogicHelper helperClass = new FileBusinessLogicHelper(); string status = helperClass.SaveFileDetails(fileObj); if (status == "empty") { TempData["AlertMessage"] = "Error"; } else if (status == "NoFile") { TempData["AlertMessage"] = "NoFile"; } else { TempData["AlertMessage"] = "Sucess"; } } catch { TempData["AlertMessage"] = "Invalid"; } return(RedirectToAction("Index", "Movie")); }
public ActionResult Index() { FileBusinessLogicHelper FileViewmodel = new FileBusinessLogicHelper(); List <FileEntity> FileDetails = new List <FileEntity>(); ViewBag.UserName = System.Web.HttpContext.Current.User.Identity.Name; if (ViewBag.UserName == "admin") { FileDetails = FileViewmodel.GetFileDetails(0); } else { FileDetails = FileViewmodel.GetFileDetails(USerConfig.GetUserID()); } ViewBag.host = Request.Url.Host; return(View(FileDetails)); }