コード例 #1
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));
        }
コード例 #2
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));
            }
        }