public ActionResult Add(LegalEntityBranchView legalEntityBranchView, FormCollection form, int?legalEntityFK) { if (ModelState.IsValid) { ILegalEntityBranchesRepository legalEntityBranchesRepository = new LegalEntityBranchesRepository(db); LegalEntityBranch legalEntityBranch = new LegalEntityBranch(); legalEntityBranchView.ConvertTo(legalEntityBranchView, legalEntityBranch); legalEntityBranchesRepository.Add(legalEntityBranch); legalEntityBranchesRepository.SaveChanges(); TempData["message"] = LayoutHelper.GetMessage("INSERT", legalEntityBranch.LegalEntityBranchPK); if (TempData["legalEntityFK"] != null) { return(RedirectToAction("Index", "LegalEntity")); } else { return(RedirectToAction("Index", "LegalEntityBranch")); } } else { legalEntityBranchView.BindDDLs(legalEntityBranchView, db); return(View(legalEntityBranchView)); } }
public ActionResult Delete(int?legalEntityBranchPK) { ILegalEntityBranchesRepository legalEntityBranchesRepository = new LegalEntityBranchesRepository(db); if (legalEntityBranchPK != null) { LegalEntityBranch legalEntityBranch = legalEntityBranchesRepository.GetLegalEntityBranchByPK((int)legalEntityBranchPK); legalEntityBranch.Deleted = true; legalEntityBranchesRepository.SaveChanges(); TempData["message"] = LayoutHelper.GetMessage("DELETE", legalEntityBranch.LegalEntityBranchPK); } return(Redirect(Request.UrlReferrer.AbsoluteUri)); }
public void ConvertTo(LegalEntityBranchView legalEntityBranchView, LegalEntityBranch legalEntityBranch) { legalEntityBranch.LegalEntityBranchPK = legalEntityBranchView.LegalEntityBranchPK; legalEntityBranch.Name = legalEntityBranchView.Name; legalEntityBranch.LegalEntityFK = legalEntityBranchView.LegalEntityFK; legalEntityBranch.CountryFK = legalEntityBranchView.CountryFK; legalEntityBranch.CountyFK = legalEntityBranchView.CountyFK; legalEntityBranch.CityCommunityFK = legalEntityBranchView.CityCommunityFK; legalEntityBranch.PostalOfficeFK = legalEntityBranchView.PostalOfficeFK; legalEntityBranch.PlaceFK = legalEntityBranchView.PlaceFK; legalEntityBranch.StreetName = legalEntityBranchView.StreetName; legalEntityBranch.Phone = legalEntityBranchView.Phone; legalEntityBranch.Fax = legalEntityBranchView.Fax; legalEntityBranch.Mobile = legalEntityBranchView.Mobile; legalEntityBranch.EMail = legalEntityBranchView.EMail; legalEntityBranch.ChangeDate = legalEntityBranchView.ChangeDate; legalEntityBranch.Deleted = legalEntityBranchView.Deleted; }
public ActionResult Edit(int?legalEntityBranchPK) { if (legalEntityBranchPK != null) { ILegalEntityBranchesRepository legalEntityBranchesRepository = new LegalEntityBranchesRepository(db); LegalEntityBranch branch = legalEntityBranchesRepository.GetLegalEntityBranchByPK((int)legalEntityBranchPK); LegalEntityBranchView legalEntityBranchView = new LegalEntityBranchView(); legalEntityBranchView.ConvertFrom(branch, legalEntityBranchView, db); legalEntityBranchView.BindDDLs(legalEntityBranchView, db); return(View(legalEntityBranchView)); } else { return(RedirectToAction("Index", "LegalEntityBranch")); } }
public ActionResult Edit(LegalEntityBranchView legalEntityBranchView, FormCollection form) { if (ModelState.IsValid) { ILegalEntityBranchesRepository legalEntityBranchesRepository = new LegalEntityBranchesRepository(db); LegalEntityBranch legalEntityBranch = legalEntityBranchesRepository.GetLegalEntityBranchByPK((int)legalEntityBranchView.LegalEntityBranchPK); legalEntityBranchView.ConvertTo(legalEntityBranchView, legalEntityBranch); legalEntityBranchesRepository.SaveChanges(); TempData["message"] = LayoutHelper.GetMessage("UPDATE", legalEntityBranch.LegalEntityBranchPK); return(RedirectToAction("Index", "LegalEntityBranch")); } else { legalEntityBranchView.BindDDLs(legalEntityBranchView, db); return(View(legalEntityBranchView)); } }
public void ConvertFrom(LegalEntityBranch legalEntityBranch, LegalEntityBranchView legalEntityBranchView, ObjectContext db) { legalEntityBranchView.LegalEntityBranchPK = legalEntityBranch.LegalEntityBranchPK; legalEntityBranchView.Name = legalEntityBranch.Name; legalEntityBranchView.LegalEntityFK = legalEntityBranch.LegalEntityFK; legalEntityBranchView.CountryFK = legalEntityBranch.CountryFK; legalEntityBranchView.CountyFK = legalEntityBranch.CountyFK; legalEntityBranchView.CityCommunityFK = legalEntityBranch.CityCommunityFK; legalEntityBranchView.PostalOfficeFK = legalEntityBranch.PostalOfficeFK; legalEntityBranchView.PlaceFK = legalEntityBranch.PlaceFK; legalEntityBranchView.StreetName = legalEntityBranch.StreetName; legalEntityBranchView.Phone = legalEntityBranch.Phone; legalEntityBranchView.Fax = legalEntityBranch.Fax; legalEntityBranchView.Mobile = legalEntityBranch.Mobile; legalEntityBranchView.EMail = legalEntityBranch.EMail; legalEntityBranchView.Deleted = legalEntityBranch.Deleted; ILegalEntitiesRepository legalEntitiesRepository = new LegalEntitiesRepository(db); LegalEntity legalEntity = legalEntitiesRepository.GetLegalEntityByPK((int)legalEntityBranchView.LegalEntityFK); legalEntityBranchView.LegalEntityName = legalEntity.Name + " (" + legalEntity.OIB + ")"; }