public ActionResult Edit(ContractValidityView contractValidityModel) { if (ModelState.IsValid) { IContractValiditiesRepository contractValiditiesRepository = new ContractValiditiesRepository(db); ContractValidity contractValidity = contractValiditiesRepository.GetContractValidityByPK((int)contractValidityModel.ContractValidityPK); contractValidityModel.ConvertTo(contractValidityModel, contractValidity); contractValiditiesRepository.SaveChanges(); TempData["message"] = LayoutHelper.GetMessage("UPDATE", contractValidity.ContractValidityPK); return(RedirectToAction("Index", "ContractValidity")); } else { return(View(contractValidityModel)); } }
public ActionResult Add(ContractValidityView contractValidityView) { if (ModelState.IsValid) { IContractValiditiesRepository contractValiditiesRepository = new ContractValiditiesRepository(db); ContractValidity contractValidity = new ContractValidity(); contractValidityView.ConvertTo(contractValidityView, contractValidity); contractValiditiesRepository.Add(contractValidity); contractValiditiesRepository.SaveChanges(); TempData["message"] = LayoutHelper.GetMessage("INSERT", contractValidity.ContractValidityPK); return(RedirectToAction("Index", "ContractValidity")); } else { return(View(contractValidityView)); } }