示例#1
0
        public IHttpActionResult PostCity(CityBindingModel model)
        {
            try {
                if (!ModelState.IsValid)
                {
                    return BadRequest(ModelState);
                }

                if (!ModelState.IsValid)
                {
                    return BadRequest(ModelState);
                }
                CityModel cityModel = new CityModel();
                AutoMapper.Mapper.Map(model, cityModel);
                cityModel = cityService.SaveCity(cityModel);
                AutoMapper.Mapper.Map(cityModel, model);
                return Ok(model);
            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                return BadRequest(ex.Message);
            }
        }
示例#2
0
 public IHttpActionResult PutCity(CityBindingModel model)
 {
     try {
         if (!ModelState.IsValid)
         {
             return BadRequest(ModelState);
         }
         CityModel cityModel = new CityModel();
         AutoMapper.Mapper.Map(model, cityModel);
         cityModel = cityService.UpadteCity(cityModel);
         AutoMapper.Mapper.Map(cityModel, model);
         return Ok(model);
     }
     catch(Exception ex)
     {
         return BadRequest(ex.Message);
     }
 }