public async Task ExecuteAsync(DeleteStewardessCommand command)
        {
            var stewardess = await _stewardessRepository.GetById(command.StewardessId);

            if (stewardess == null)
            {
                throw new Exception("Stewardess with this Id does not exist");
            }

            await _stewardessRepository.Delete(stewardess);
        }
Example #2
0
        public async Task ExecuteAsync(CreateStewardessCommand command)
        {
            if (await _stewardessRepository.GetById(command.Id) != null)
            {
                throw new Exception("Stewardess with same Id already exists");
            }

            var stewardess = _mapper.Map <Airport.Domain.Entities.Stewardess>(command);

            await _stewardessRepository.Create(stewardess);
        }
Example #3
0
        public async Task <StewardessByIdResponse> ExecuteAsync(StewardessByIdQuery request)
        {
            var stewardess = await _stewardessRepository.GetById(request.StewardessId);

            if (stewardess == null)
            {
                throw new Exception("Stewardess not found");
            }

            var mappedStewardess = _mapper.Map <StewardessByIdResponse>(stewardess);

            return(mappedStewardess);
        }
Example #4
0
        public async Task ExecuteAsync(UpdateStewardressCommand command)
        {
            var stewardess = await _stewardessRepository.GetById(command.Id);

            if (stewardess == null)
            {
                throw new Exception("Stewardess with this Id does not exist");
            }

            stewardess.FirstName   = command.FirstName ?? stewardess.FirstName;
            stewardess.LastName    = command.LastName ?? stewardess.LastName;
            stewardess.DateOfBirth = command.DateOfBirth;

            await _stewardessRepository.Update(stewardess);
        }