Example #1
0
        public ActionResult Add()
        {
            CountyView countyView = new CountyView();

            countyView.BindDDLs(countyView, db);

            return(View(countyView));
        }
Example #2
0
        public ActionResult Edit(int?countyPK)
        {
            if (countyPK != null)
            {
                ICountiesRepository countiesRepository = new CountiesRepository(db);
                County     county     = countiesRepository.GetCountyByPK((int)countyPK);
                CountyView countyView = new CountyView();

                countyView.ConvertFrom(county, countyView);
                countyView.BindDDLs(countyView, db);

                return(View(countyView));
            }
            else
            {
                return(RedirectToAction("Index", "County"));
            }
        }
Example #3
0
        public ActionResult Edit(CountyView countyView, FormCollection form)
        {
            if (ModelState.IsValid)
            {
                ICountiesRepository countiesRepository = new CountiesRepository(db);
                County county = countiesRepository.GetCountyByPK((int)countyView.CountyPK);

                countyView.ConvertTo(countyView, county);

                countiesRepository.SaveChanges();

                TempData["message"] = LayoutHelper.GetMessage("UPDATE", county.CountyPK);

                return(RedirectToAction("Index", "County"));
            }
            else
            {
                countyView.BindDDLs(countyView, db);

                return(View(countyView));
            }
        }