public async Task ExecuteAsync(DeleteAirCraftTypeCommand command) { var airCraftType = await _airCraftTypeRepository.GetById(command.AirCraftTypeId); if (airCraftType == null) { throw new Exception("AirCraftType with this Id does not exist"); } await _airCraftTypeRepository.Delete(airCraftType.Id); }
public async Task ExecuteAsync(CreateAirCraftTypeCommand command) { if (await _airCraftTypeRepository.GetById(command.Id) != null) { throw new Exception("AirCraftType with same Id already exists"); } var airCraftType = _mapper.Map <Airport.Domain.Entities.AirCraftType>(command); await _airCraftTypeRepository.Create(airCraftType); }
public async Task <AirCraftTypeByIdResponse> ExecuteAsync(AirCraftTypeByIdQuery request) { var airCraftType = await _airCraftTypeRepository.GetById(request.AirCraftTypeId); if (airCraftType == null) { throw new Exception("Idea not found"); } var mappedAirCraftType = _mapper.Map <AirCraftTypeByIdResponse>(airCraftType); return(mappedAirCraftType); }
public async Task ExecuteAsync(UpdateAirCraftTypeCommand command) { var airCraftType = await _airCraftTypeRepository.GetById(command.AirCraftTypeId); if (airCraftType == null) { throw new Exception("AirCraftType with this Id does not exist"); } airCraftType.LoadCapacity = command.LoadCapacity; airCraftType.Model = command.Model ?? airCraftType.Model; airCraftType.Seats = command.Seats; await _airCraftTypeRepository.Update(airCraftType); }