/// <summary> /// Обновление координат места происшествия /// </summary> /// <param name="locationDto"></param> /// <returns></returns> public async Task <Result> UpdateLocationAsync(UpdateLocationDto locationDto) { using (_unitOfWork.Begin()) { var caseFolderId = locationDto.CaseFolderId; var caseFolder = await _caseFolderRepository.GetById(caseFolderId); if (caseFolder == null) { _logger.Warning($"CaseFolser with Id {caseFolderId} not found"); return(Result.Failure(ErrorCodes.CaseFolderNotFound)); } if (locationDto.CoordinateFieldType == CoordinateFieldType.Latitude) { caseFolder.Latitude = locationDto.Value; } else if (locationDto.CoordinateFieldType == CoordinateFieldType.Longitude) { caseFolder.Longitude = locationDto.Value; } else { _logger.Warning("Unknown coordinate field type to update"); return(Result.Failure(ErrorCodes.ValidationError)); } await _unitOfWork.CommitAsync(); await _phoneHubMessageService.NotifyClientsAboutLocationUpdateAsync(caseFolderId, locationDto.OperatorId); return(Result.Success()); } }
public IActionResult Put(int id, [FromBody] UpdateLocationDto model) => _mapper.Map <LocationUpdateModel>(model) .Map(x => _commandRepository.Update(id, x)) .Map(x => AllOk(new { updated = x })) .Reduce(_ => NotFound(), error => error is RecordNotFound) .Reduce(_ => BadRequest(), error => error is ArgumentNotSet) .Reduce(_ => InternalServerError(), x => _logger.LogError(x.ToString()));
public IActionResult UpdateLocation([FromBody] UpdateLocationDto locationDto) { if (!ModelState.IsValid) { return(BadRequest()); } _locationServices.UpdateLocation(locationDto); return(Ok()); }
public void UpdateLocation(UpdateLocationDto updateLocationDto) { Location @location = new Location() { Id = updateLocationDto.Id, Country = updateLocationDto.Country, City = updateLocationDto.City, Street = updateLocationDto.Street, HouseNumber = updateLocationDto.HouseNumber, FlatNumber = updateLocationDto.FlatNumber }; _locationrepository.Update(@location); }
public async Task <demoResult> UpdateLocation([FromBody] UpdateLocationDto locationDto) { if (locationDto == null || !locationDto.IsValid()) { _logger.Warning($"Model not valid"); return(BadRequest(ErrorCodes.ValidationError)); } var result = await _caseService.UpdateLocationAsync(locationDto); if (result.IsFailure) { return(BadRequest(result.ErrorCode)); } return(Ok()); }