public ActionResult Create(ContainerViewModel model) { var automapperVesselVisit = AutoMapper.Mapper.Map<Container>(model); context.Container.Add(automapperVesselVisit); context.SaveChanges(); return RedirectToAction("Index"); }
public ActionResult SaveDocuments(ContainerViewModel model) { // Use your file here f foreach (var f in model.File) { var arrayBytes = ReadFully(f.InputStream); File(arrayBytes, f.ContentType); Documents entity = new Documents { document = arrayBytes, name = f.FileName, type = f.ContentType }; context.Documents.Add(entity); context.SaveChanges(); } //File.WriteAllBytes(model.File.InputStream, arrayBytes); return RedirectToAction("Information", new { id = model.GKey }); }