Beispiel #1
0
 public void ConvertTo(CityCommunityView cityCommunityView, CityCommunity cityCommunity)
 {
     cityCommunity.CityCommunityPK = cityCommunityView.CityCommunityPK;
     cityCommunity.Name            = cityCommunityView.Name;
     cityCommunity.Code            = cityCommunityView.Code;
     cityCommunity.CountyFK        = cityCommunityView.CountyFK;
 }
Beispiel #2
0
        public void ConvertFrom(CityCommunity cityCommunity, CityCommunityView cityCommunityView, ObjectContext db)
        {
            cityCommunityView.CityCommunityPK = cityCommunity.CityCommunityPK;
            cityCommunityView.Name            = cityCommunity.Name;
            cityCommunityView.Code            = cityCommunity.Code;
            cityCommunityView.CountyFK        = cityCommunity.CountyFK;

            //get country id
            ICountiesRepository countiesRepository = new CountiesRepository(db);

            cityCommunityView.CountryFK = countiesRepository.GetCountyByPK((int)cityCommunityView.CountyFK).CountryFK;
        }
Beispiel #3
0
        public ActionResult Delete(int?cityCommunityPK)
        {
            ICitiesCommunitiesRepository citiesCommunitiesRepository = new CitiesCommunitiesRepository(db);

            if (cityCommunityPK != null)
            {
                CityCommunity cityCommunity = citiesCommunitiesRepository.GetCityCommunityByPK((int)cityCommunityPK);

                cityCommunity.Deleted = true;

                citiesCommunitiesRepository.SaveChanges();

                TempData["message"] = LayoutHelper.GetMessage("DELETE", cityCommunity.CityCommunityPK);
            }

            return(Redirect(Request.UrlReferrer.AbsoluteUri));
        }
Beispiel #4
0
        public ActionResult Edit(int?cityCommunityPK)
        {
            if (cityCommunityPK != null)
            {
                ICitiesCommunitiesRepository citiesCommunitiesRepository = new CitiesCommunitiesRepository(db);
                CityCommunity     cityCommunity     = citiesCommunitiesRepository.GetCityCommunityByPK((int)cityCommunityPK);
                CityCommunityView cityCommunityView = new CityCommunityView();

                cityCommunityView.ConvertFrom(cityCommunity, cityCommunityView, db);
                cityCommunityView.BindDDLs(cityCommunityView, db);

                return(View(cityCommunityView));
            }
            else
            {
                return(RedirectToAction("Index", "CityCommunity"));
            }
        }
Beispiel #5
0
        public ActionResult Edit(CityCommunityView cityCommunityView, FormCollection form)
        {
            if (ModelState.IsValid)
            {
                ICitiesCommunitiesRepository citiesCommunitiesRepository = new CitiesCommunitiesRepository(db);
                CityCommunity cityCommunity = citiesCommunitiesRepository.GetCityCommunityByPK((int)cityCommunityView.CityCommunityPK);
                cityCommunityView.ConvertTo(cityCommunityView, cityCommunity);

                citiesCommunitiesRepository.SaveChanges();

                TempData["message"] = LayoutHelper.GetMessage("UPDATE", cityCommunity.CityCommunityPK);

                return(RedirectToAction("Index", "CityCommunity"));
            }
            else
            {
                cityCommunityView.BindDDLs(cityCommunityView, db);
                return(View(cityCommunityView));
            }
        }