public ActionResult attachCircular(CircularsPath circularsPath) { foreach (var file in circularsPath.circularFileName) { if (file != null) { Random random = new Random(); FileInfo fi = new FileInfo(file.FileName); DateTime d = DateTime.Now; var InputFileName = fi.Name; var ServerSavePath = System.IO.Path.Combine(Server.MapPath("~/Content"), InputFileName + fi.Extension); //Save file to server folder file.SaveAs(ServerSavePath); circularsPath.fileName = InputFileName; } } Circular circular = new Circular() { fileName = circularsPath.fileName, fileDate = DateTime.Today, factoryId = int.Parse(circularsPath.factId), download = false }; context.Circulars.Add(circular); context.SaveChanges(); return(RedirectToAction("Home", "Home", new { id = 1 })); }
// GET: Circular public ActionResult attachCircular() { var q = context.Factory11.Select(x => new SelectListItem { Text = x.Name, Value = x.Id.ToString() }).ToList(); CircularsPath circulars = new CircularsPath(); circulars.facts = q; return(View(circulars)); }