Пример #1
0
        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));
            }
        }
Пример #2
0
        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));
            }
        }