public ActionResult Add(LegalEntityLegalRepresentativeView legalEntityLegalRepresentativeView, FormCollection form) { if (ModelState.IsValid) { ILegalEntityLegalRepresentativesRepository legalEntityLegalRepresentativesRepository = new LegalEntityLegalRepresentativesRepository(db); LegalEntityLegalRepresentative legalEntityLegalRepresentative = new LegalEntityLegalRepresentative(); legalEntityLegalRepresentativeView.ConvertTo(legalEntityLegalRepresentativeView, legalEntityLegalRepresentative); legalEntityLegalRepresentativesRepository.Add(legalEntityLegalRepresentative); legalEntityLegalRepresentativesRepository.SaveChanges(); TempData["message"] = LayoutHelper.GetMessage("INSERT", legalEntityLegalRepresentative.LegalEntityLegalRepresentativePK); if (TempData["legalEntityFK"] != null) { return(RedirectToAction("Index", "LegalEntity")); } else { return(RedirectToAction("Index", "LegalEntityLegalRepresentative")); } } else { legalEntityLegalRepresentativeView.BindDDLs(legalEntityLegalRepresentativeView, db); return(View(legalEntityLegalRepresentativeView)); } }
public ActionResult Edit(LegalEntityLegalRepresentativeView legalEntityLegalRepresentativeView, FormCollection form) { if (ModelState.IsValid) { ILegalEntityLegalRepresentativesRepository legalEntityLegalRepresentativesRepository = new LegalEntityLegalRepresentativesRepository(db); LegalEntityLegalRepresentative legalEntityLegalRepresentative = legalEntityLegalRepresentativesRepository.GetLegalEntityLegalRepresentativeByPK((int)legalEntityLegalRepresentativeView.LegalEntityLegalRepresentativePK); legalEntityLegalRepresentativeView.ConvertTo(legalEntityLegalRepresentativeView, legalEntityLegalRepresentative); legalEntityLegalRepresentativesRepository.SaveChanges(); TempData["message"] = LayoutHelper.GetMessage("UPDATE", legalEntityLegalRepresentative.LegalEntityLegalRepresentativePK); return(RedirectToAction("Index", "LegalEntityLegalRepresentative")); } else { legalEntityLegalRepresentativeView.BindDDLs(legalEntityLegalRepresentativeView, db); return(View(legalEntityLegalRepresentativeView)); } }