public async Task <ActionResult> GetOfficeAsync(int officeId) { var office = await _officesRepository.GetAsync(officeId); if (office == null) { throw ApiException.NotFound("Office not found"); } return(Ok(_mapper.Map <OfficeModel>(office))); }
public async Task <PlayerGet> Handle(PlayerGetRequest request, CancellationToken cancellationToken) { var player = await _repository.Get(request.Id); if (player == null) { throw ApiException.NotFound(request.Id); } player.Badges = await _badgesClient.Get(request.Id); return(player); }
public async Task <ActionResult> DeleteOfficeAsync(int officeId) { var office = await _officesRepository.GetAsync(officeId); if (office == null) { throw ApiException.NotFound("Office not found"); } await _officesRepository.DeleteAsync(office); return(Ok()); }
private async Task <Door> GetAndEnsureDoorAsync(int officeId, int doorId) { var door = await _doorsRepository.GetAsync(doorId); if (door == null) { throw ApiException.NotFound("Door not found"); } if (door.OfficeId != officeId) { throw ApiException.NotFound("Door not found"); } return(door); }
public async Task <ActionResult> CreateDoorAsync(int officeId, [FromBody] CreateDoorRequest request) { if (request == null) { return(BadRequest()); } var office = await _officesRepository.GetAsync(officeId); if (office == null) { throw ApiException.NotFound("Office not found"); } var door = _mapper.Map <Door>(request); var doorId = await _officesRepository.AddDoorAsync(office, door); return(Ok(new CreateDoorResponse { DoorId = doorId })); }