public ActionResult Edit(ChangeTypeView changeTypeModel) { if (ModelState.IsValid) { IChangeTypesRepository changeTypesRepository = new ChangeTypesRepository(db); ChangeType changeType = changeTypesRepository.GetChangeTypeByPK((int)changeTypeModel.ChangeTypePK); changeTypeModel.ConvertTo(changeTypeModel, changeType); changeTypesRepository.SaveChanges(); TempData["message"] = LayoutHelper.GetMessage("UPDATE", changeType.ChangeTypePK); return(RedirectToAction("Index", "ChangeType")); } else { return(View(changeTypeModel)); } }
public ActionResult Add(ChangeTypeView changeTypeView) { if (ModelState.IsValid) { IChangeTypesRepository changeTypesRepository = new ChangeTypesRepository(db); ChangeType changeType = new ChangeType(); changeTypeView.ConvertTo(changeTypeView, changeType); changeTypesRepository.Add(changeType); changeTypesRepository.SaveChanges(); TempData["message"] = LayoutHelper.GetMessage("INSERT", changeType.ChangeTypePK); return(RedirectToAction("Index", "ChangeType")); } else { return(View(changeTypeView)); } }