/// <summary> /// 站点更新 /// </summary> /// <param name="stationUpdateViewModel"></param> /// <returns></returns> public int Station_Update(StationUpdateViewModel stationUpdateViewModel) { var Station_Info = _IBusStationRepository.GetInfoByStationId(stationUpdateViewModel.Id); var Station_Info_Update = _IMapper.Map <StationUpdateViewModel, Bus_Station>(stationUpdateViewModel, Station_Info); _IBusStationRepository.Update(Station_Info_Update); return(_IBusStationRepository.SaveChanges()); }
public ActionResult UpdateCity(StationUpdateViewModel model) { if (!ModelState.IsValid) { return(BadRequest("Invalid Request")); } var updateResult = _stationService.UpdateStation(model); if (!string.IsNullOrEmpty(updateResult)) { return(StatusCode((int)HttpStatusCode.NotAcceptable, updateResult)); } return(Ok()); }
public string UpdateStation(StationUpdateViewModel model) { var existedStation = _StationRepository.Get(x => x.Deleted == false && x.Id == model.Id); if (existedStation == null) { return("Not found Station"); } existedStation.Name = model.Name; existedStation.CityId = model.CityId; _StationRepository.Update(existedStation); try { _unitOfWork.CommitChanges(); } catch (Exception ex) { return(ex.Message); } return(string.Empty); }
public ActionResult <StationUpdateResModel> Manage_Station_Update(StationUpdateViewModel stationeUpdateViewModel) { StationUpdateResModel stationUpdateResModel = new StationUpdateResModel(); int UpdateRowNum = _stationService.Station_Update(stationeUpdateViewModel); if (UpdateRowNum > 0) { stationUpdateResModel.IsSuccess = true; stationUpdateResModel.AddCount = UpdateRowNum; stationUpdateResModel.baseViewModel.Message = "更新成功"; stationUpdateResModel.baseViewModel.ResponseCode = 200; _ILogger.Information("更新站点信息成功"); return(Ok(stationUpdateResModel)); } else { stationUpdateResModel.IsSuccess = false; stationUpdateResModel.AddCount = 0; stationUpdateResModel.baseViewModel.Message = "更新失败"; stationUpdateResModel.baseViewModel.ResponseCode = 400; _ILogger.Information("更新站点信息失败"); return(Ok(stationUpdateResModel)); } }