public async Task <ServiceResponse <GetLocationDTO> > UpdateLocation(UpdateLocationDTO updatedLocation) { ServiceResponse <GetLocationDTO> serviceResponse = new ServiceResponse <GetLocationDTO>(); try { Location l = await _context.Locations.Where(l => l.IsDeleted == false) .FirstOrDefaultAsync(l => l.Id == updatedLocation.Id); l.SquareMeters = updatedLocation.SquareMeters; if (updatedLocation.Capacity != 0) { l.Capacity = updatedLocation.Capacity; } if (updatedLocation.Address != null) { l.Address = updatedLocation.Address; } _context.Locations.Update(l); await _context.SaveChangesAsync(); serviceResponse.Data = _mapper.Map <GetLocationDTO>(l); } catch (Exception exc) { serviceResponse.Success = false; serviceResponse.Message = exc.Message; } return(serviceResponse); }
public async Task UpdateLocation(UpdateLocationDTO input) { var location = _mapper.Map <Location>(input); location.Project = await _projectRepository.GetById(input.ProjectId); await _repository.Update(location.Id, location); }
public async Task <IActionResult> Update(UpdateLocationDTO l) { ServiceResponse <GetLocationDTO> response = await _locationService.UpdateLocation(l); if (response.Data == null) { return(NotFound(response)); } return(Ok(response)); }
public async Task <IActionResult> UpdateLocation([FromBody] UpdateLocationDTO updatedLocation) { var result = await LocationActor.Ask( new AskToUpdateLocation( updatedLocation.Fields, updatedLocation.Location ), TimeSpan.FromSeconds(15) ); return(ValidateActorResult(result)); }
public async Task <IActionResult> UpdateLocation(UpdateLocationDTO input) { try { await _locationService.UpdateLocation(input); return(Ok("The process is success")); } catch (Exception) { return(BadRequest("An error occurred during the updating process. Please try again !")); } }
public async Task <IActionResult> PutLocation(int id, UpdateLocationDTO location) { if (id != location.Id) { return(BadRequest()); } var completed = await locationsService.PutLocation(id, mapper.Map <Location>(location)); if (!completed) { return(NotFound()); } else { return(Ok()); } }