コード例 #1
0
        public ActionResult Edit(RegionalOfficeView regionalOfficeModel)
        {
            if (ModelState.IsValid)
            {
                IRegionalOfficesRepository regionalOfficesRepository = new RegionalOfficesRepository(db);
                RegionalOffice             regionalOffice            = regionalOfficesRepository.GetRegionalOfficeByPK((int)regionalOfficeModel.RegionalOfficePK);
                regionalOfficeModel.ConvertTo(regionalOfficeModel, regionalOffice);

                regionalOfficesRepository.SaveChanges();

                TempData["message"] = LayoutHelper.GetMessage("UPDATE", regionalOffice.RegionalOfficePK);

                return(RedirectToAction("Index", "RegionalOffice"));
            }
            else
            {
                return(View(regionalOfficeModel));
            }
        }
コード例 #2
0
        public ActionResult Add(RegionalOfficeView regionalOfficeView)
        {
            if (ModelState.IsValid)
            {
                IRegionalOfficesRepository regionalOfficesRepository = new RegionalOfficesRepository(db);
                RegionalOffice             regionalOffice            = new RegionalOffice();

                regionalOfficeView.ConvertTo(regionalOfficeView, regionalOffice);

                regionalOfficesRepository.Add(regionalOffice);
                regionalOfficesRepository.SaveChanges();

                TempData["message"] = LayoutHelper.GetMessage("INSERT", regionalOffice.RegionalOfficePK);

                return(RedirectToAction("Index", "RegionalOffice"));
            }
            else
            {
                return(View(regionalOfficeView));
            }
        }