示例#1
0
        public IHttpActionResult GetCityByID(int CityId)
        {
            var city = _cityservice.GetCity(CityId);

            Mapper.CreateMap <CommunicationApp.Entity.City, CommunicationApp.Models.CityModel>();
            CommunicationApp.Models.CityModel citymodel = Mapper.Map <CommunicationApp.Entity.City, CommunicationApp.Models.CityModel>(city);
            return(Json(citymodel));
        }
        // GET: /City/Delete/5
        public ActionResult Delete(int id)
        {
            UserPermissionAction("City", RoleAction.delete.ToString());
            CheckPermission();
            if (id <= 0)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            City city = _CityService.GetCity(id);

            Mapper.CreateMap <CommunicationApp.Entity.City, CommunicationApp.Models.CityModel>();
            CommunicationApp.Models.CityModel citymodel = Mapper.Map <CommunicationApp.Entity.City, CommunicationApp.Models.CityModel>(city);
            if (citymodel == null)
            {
                return(HttpNotFound());
            }
            return(View(citymodel));
        }
        // GET: /City/Edit/5
        public ActionResult Edit(int id)
        {
            UserPermissionAction("City", RoleAction.edit.ToString());
            CheckPermission();
            if (id <= 0)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            City city = _CityService.GetCity(id);

            Mapper.CreateMap <CommunicationApp.Entity.City, CommunicationApp.Models.CityModel>();
            CommunicationApp.Models.CityModel citymodel = Mapper.Map <CommunicationApp.Entity.City, CommunicationApp.Models.CityModel>(city);
            if (citymodel == null)
            {
                return(HttpNotFound());
            }
            ViewBag.StateID = new SelectList(_CityService.GetCities(), "StateID", "StateName", city.StateID);
            return(View(citymodel));
        }