public async Task <IActionResult> Get(int id) { try { var house = await _houseRepository.GetByIdAsync(id); if (house == null) { return(NotFound()); } return(Ok(new HouseConverter().Convert(house))); } catch (Exception ex) { return(StatusCode(500, ex)); } }
public async Task <House.Models.House> Handle(HouseQueryCommand request, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(request.HouseId)) { return(null); } return(await _houseRepository.GetByIdAsync(request.HouseId)); }
public async Task Handle(HouseTradedEvent notification, CancellationToken cancellationToken) { House.Models.House house = await _houseRepository.GetByIdAsync(notification.HouseId); if (house != null) { house.TradeTo(notification.BuyerId); _houseRepository.Update(house); await _unitOfWork.CommitAsync(); } }
public async Task <Result> UpdateNameAsync(string houseId, string name) { if (string.IsNullOrEmpty(houseId)) { throw new ArgumentNullException(nameof(houseId)); } if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException(nameof(name)); } Models.House house = await _houseRepository.GetByIdAsync(houseId); if (house == null) { return(Result.Fail("Production not exist.")); } house.UpdateName(name); _houseRepository.Update(house); return(Result.Success()); }
[HttpGet("{id}")] //api/house/id public async Task <House> GetHouse(string id) { return(await _houseRepository.GetByIdAsync(id)); }
public async Task <HouseDto> GetHouseAsync(string houseId) { House house = await _houseRepository.GetByIdAsync(houseId); return(_mapper.Map <HouseDto>(house)); }
public async Task <HouseToUpdate> GetByIdAsync(int id) { var entity = await _repository.GetByIdAsync(id); return(_mapper.Map <HouseToUpdate>(entity)); }