예제 #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;
 }