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 void ConvertFrom(LegalEntityLegalRepresentative legalEntityLegalRepresentative, LegalEntityLegalRepresentativeView legalEntityLegalRepresentativeView, ObjectContext db) { legalEntityLegalRepresentativeView.LegalEntityLegalRepresentativePK = legalEntityLegalRepresentative.LegalEntityLegalRepresentativePK; legalEntityLegalRepresentativeView.LegalEntityFK = legalEntityLegalRepresentative.LegalEntityFK; legalEntityLegalRepresentativeView.WayOfRepresentationFK = legalEntityLegalRepresentative.WayOfRepresentationFK; legalEntityLegalRepresentativeView.LegalRepresentativeFK = legalEntityLegalRepresentative.LegalRepresentativeFK; legalEntityLegalRepresentativeView.Deleted = legalEntityLegalRepresentative.Deleted; ILegalEntitiesRepository legalEntitiesRepository = new LegalEntitiesRepository(db); LegalEntity legalEntity = legalEntitiesRepository.GetLegalEntityByPK((int)legalEntityLegalRepresentative.LegalEntityFK); legalEntityLegalRepresentativeView.LegalEntityName = legalEntity.Name + " (" + legalEntity.OIB + ")"; }
public ActionResult Delete(int?legalEntityLegalRepresentativePK) { ILegalEntityLegalRepresentativesRepository legalEntityLegalRepresentativesRepository = new LegalEntityLegalRepresentativesRepository(db); if (legalEntityLegalRepresentativePK != null) { LegalEntityLegalRepresentative legalEntityLegalRepresentative = legalEntityLegalRepresentativesRepository.GetLegalEntityLegalRepresentativeByPK((int)legalEntityLegalRepresentativePK); legalEntityLegalRepresentative.Deleted = true; legalEntityLegalRepresentativesRepository.SaveChanges(); TempData["message"] = LayoutHelper.GetMessage("DELETE", legalEntityLegalRepresentative.LegalEntityLegalRepresentativePK); } return(Redirect(Request.UrlReferrer.AbsoluteUri)); }
public ActionResult Edit(int?legalEntityLegalRepresentativePK) { if (legalEntityLegalRepresentativePK != null) { ILegalEntityLegalRepresentativesRepository legalEntityLegalRepresentativesRepository = new LegalEntityLegalRepresentativesRepository(db); LegalEntityLegalRepresentative legalEntityLegalRepresentative = legalEntityLegalRepresentativesRepository.GetLegalEntityLegalRepresentativeByPK((int)legalEntityLegalRepresentativePK); LegalEntityLegalRepresentativeView legalEntityLegalRepresentativeView = new LegalEntityLegalRepresentativeView(); legalEntityLegalRepresentativeView.ConvertFrom(legalEntityLegalRepresentative, legalEntityLegalRepresentativeView, db); legalEntityLegalRepresentativeView.BindDDLs(legalEntityLegalRepresentativeView, db); return(View(legalEntityLegalRepresentativeView)); } else { return(RedirectToAction("Index", "LegalEntityLegalRepresentative")); } }
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)); } }
public void ConvertTo(LegalEntityLegalRepresentativeView legalEntityLegalRepresentativeView, LegalEntityLegalRepresentative legalEntityLegalRepresentative) { legalEntityLegalRepresentative.LegalEntityFK = legalEntityLegalRepresentativeView.LegalEntityFK; legalEntityLegalRepresentative.WayOfRepresentationFK = legalEntityLegalRepresentativeView.WayOfRepresentationFK; legalEntityLegalRepresentative.LegalRepresentativeFK = legalEntityLegalRepresentativeView.LegalRepresentativeFK; legalEntityLegalRepresentative.ChangeDate = legalEntityLegalRepresentativeView.ChangeDate; legalEntityLegalRepresentative.Deleted = legalEntityLegalRepresentativeView.Deleted; }