Exemple #1
0
            public async Task <Response <Position> > Handle(GetPositionByIdQuery query, CancellationToken cancellationToken)
            {
                var position = await _positionRepository.GetByIdAsync(query.Id);

                if (position == null)
                {
                    throw new ApiException($"Position Not Found.");
                }
                return(new Response <Position>(position));
            }
            public async Task <Response <Guid> > Handle(DeletePositionByIdCommand command, CancellationToken cancellationToken)
            {
                var position = await _positionRepository.GetByIdAsync(command.Id);

                if (position == null)
                {
                    throw new ApiException($"Position Not Found.");
                }
                await _positionRepository.DeleteAsync(position);

                return(new Response <Guid>(position.Id));
            }
Exemple #3
0
            public async Task <Response <Guid> > Handle(UpdatePositionCommand command, CancellationToken cancellationToken)
            {
                var position = await _positionRepository.GetByIdAsync(command.Id);

                if (position == null)
                {
                    throw new ApiException($"Position Not Found.");
                }
                else
                {
                    position.PositionTitle       = command.Title;
                    position.PositionSalary      = command.Salary;
                    position.PositionDescription = command.Description;
                    await _positionRepository.UpdateAsync(position);

                    return(new Response <Guid>(position.Id));
                }
            }