public ActionResult Edit(ServiceAdminEditViewModel service) { if (ModelState.IsValid) { Service dBService = db.Services.Find(service.ServiceId); dBService.FirstName = service.FirstName; dBService.LastName = service.LastName; dBService.Obituary = service.Obituary; dBService.Birthday = service.Birthday; dBService.DeathDay = service.DeathDay; dBService.ServiceDate = service.ServiceDate; dBService.ContactEmail = service.ContactEmail; if (dBService.Video != null) { dBService.Video.ConvertedFilePath = service.ConvertedFilePath; dBService.Video.Status = service.Status; dBService.Video.OldVideoId = service.OldVideoId; } db.Entry(dBService).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(service)); }
// GET: Services/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(View("NotFound")); } Service service = db.Services.Find(id); ServiceAdminEditViewModel editViewModel = new ServiceAdminEditViewModel() { FirstName = service.FirstName, LastName = service.LastName, Obituary = service.Obituary, Birthday = service.Birthday, DeathDay = service.DeathDay, ServiceDate = service.ServiceDate, ServiceId = service.Id, ContactEmail = service.ContactEmail, }; if (service.Video != null) { editViewModel.Status = service.Video.Status; editViewModel.ConvertedFilePath = service.Video.ConvertedFilePath; editViewModel.OldVideoId = service.Video.OldVideoId; } //Mapper.CreateMap(service, ) if (service == null) { return(HttpNotFound()); } return(View(editViewModel)); }