public void EditResource(ResourceEntity resource) { ResourcesRepository resRepo = new ResourcesRepository(); using (var uow = UnitOfWork.CreateUoW()) { try { resRepo.Update(EntitiesMapper.ToDbModel(resource), uow); uow.ApplyChanges(); } catch (Exception ex) { DbLog.LogError("Error editing resource " + resource, ex); throw ex; } } }
public ActionResult Edit(ResourcesEditViewModel viewModel) { ValidateResource(viewModel.Resource); if (ModelState.IsValid) { var resource = viewModel.Resource; _resourcesRepository.Update(resource); TempData["Message"] = "Your resource was successfully added."; return(RedirectToAction("Details", new { id = resource.Id })); } viewModel.Init(Repository, _sectionsRepository); return(View(viewModel)); }