public async Task <BaseResponse <int> > Update(CityUpdate model) { City city = await _db.Cities.Where(x => x.CityGuid == model.CityGuid).FirstOrDefaultAsync(); if (!string.IsNullOrEmpty(model.CityName)) { city.CityName = model.CityName; } var result = await _db.SaveChangesAsync(); if (result == 1) { return(new BaseResponse <int> { Code = RsponseCode.Success, Message = "تم تحديث بيانات المدينة بنجاح ", Data = 0 }); } return(new BaseResponse <int> { Code = RsponseCode.DataBaseError, Message = "حصل خطأ ", Data = 0 }); }
public async Task <ActionResult> UpdateCityInfo(int cityCode, CityUpdate cityToUpdate) { var cityModel = await _service.SearchCityByCode(cityCode); if (cityModel == null) { return(NotFound()); } _mapper.Map(cityToUpdate, cityModel); _service.UpdateCity(cityModel); _service.SaveChanges(); return(Ok(_service.SearchCityByCode(cityCode))); }
// 公用静态方法,修改一条记录 UpdateCity public static bool UpdateEntity(CityBusEntity obj) { if (obj == null || obj.IsEmpty) { return(false); } CityUpdate exec = new CityUpdate(); try { exec.ReceiveParameter(obj); exec.ExecNoQuery(); return(true); } catch (Exception ex) { //throw ex; return(false); } finally { obj = null; } }
public async Task <IActionResult> Update([FromBody] CityUpdate model) { var result = await _clientService.Update(model); return(Ok(result)); }