예제 #1
0
        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));
            }
        }
예제 #2
0
        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));
            }
        }