public async Task <SystemZoneResponse> PutSystemZone(int id, PutSystemZone model) { var systemZone = await _unitOfWork.Repository <SystemZone>().GetById(id); if (systemZone != null) { systemZone.Name = model.Name; systemZone.ModifyDate = DateTime.UtcNow.AddHours(7); try { await _unitOfWork.Repository <SystemZone>().Update(systemZone, id); await _unitOfWork.CommitAsync(); return(new SystemZoneResponse { Id = systemZone.Id, Name = systemZone.Name, Geom = systemZone.Geom, CreateDate = systemZone.CreateDate, WardId = systemZone.WardId, }); } catch (Exception) { throw new CrudException(HttpStatusCode.BadRequest, "Update Error!!!", null); } } else { throw new CrudException(HttpStatusCode.NotFound, "Id not founded!!!", ""); } }
public async Task <ActionResult <SystemZoneResponse> > UpdateSystemZone(int id, [FromBody] PutSystemZone model) { var rs = await _systemZoneService.PutSystemZone(id, model); return(Ok(rs)); }