コード例 #1
0
        public ActionResult Delete(int?regionalOfficePK)
        {
            IRegionalOfficesRepository regionalOfficesRepository = new RegionalOfficesRepository(db);

            if (regionalOfficePK != null)
            {
                RegionalOffice regionalOffice = regionalOfficesRepository.GetRegionalOfficeByPK((int)regionalOfficePK);

                regionalOffice.Deleted = true;

                regionalOfficesRepository.SaveChanges();

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

            return(Redirect(Request.UrlReferrer.AbsoluteUri));
        }
コード例 #2
0
        public ActionResult Edit(int?regionalOfficePK)
        {
            if (regionalOfficePK != null)
            {
                IRegionalOfficesRepository regionalOfficesRepository = new RegionalOfficesRepository(db);
                RegionalOffice             regionalOffice            = regionalOfficesRepository.GetRegionalOfficeByPK((int)regionalOfficePK);
                RegionalOfficeView         regionalOfficeView        = new RegionalOfficeView();

                regionalOfficeView.ConvertFrom(regionalOffice, regionalOfficeView);

                return(View(regionalOfficeView));
            }
            else
            {
                return(RedirectToAction("Index", "RegionalOffice"));
            }
        }
コード例 #3
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));
            }
        }
コード例 #4
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));
            }
        }
コード例 #5
0
 public void ConvertTo(RegionalOfficeView regionalOfficeView, RegionalOffice regionalOffice)
 {
     regionalOffice.RegionalOfficePK = regionalOfficeView.RegionalOfficePK;
     regionalOffice.Name             = regionalOfficeView.Name;
 }
コード例 #6
0
 public void ConvertFrom(RegionalOffice regionalOffice, RegionalOfficeView regionalOfficeView)
 {
     regionalOfficeView.RegionalOfficePK = regionalOffice.RegionalOfficePK;
     regionalOfficeView.Name             = regionalOffice.Name;
     regionalOfficeView.Deleted          = regionalOffice.Deleted;
 }