Beispiel #1
0
        public async Task <BaseCommandResponse> Handle(CreateStatusCommand request, CancellationToken cancellationToken)
        {
            var user = await userStore.FindByIdAsync(request.GetUser(), cancellationToken);

            if (user == null)
            {
                throw new UserDoesNotExistException();
            }
            if (!user.IsAdmin)
            {
                throw new UnauthorizedAccessException("User does not have permission for that action");
            }

            var newStatus = new Status(name: request.Name);

            await _statusRepository.CreateStatusAsync(newStatus);

            return(new BaseCommandResponse($"Status {newStatus.Name} created succesfully"));
        }
Beispiel #2
0
 public async Task<int> CreateStatusAsync(Status status)
 {
     return await stateRepository.CreateStatusAsync(status);
 }