Exemplo n.º 1
0
        public async Task <AddSerialResponse> Handle(AddSerialRequest request, CancellationToken cancellationToken)
        {
            var(token, email, serial) = (cryptoService.Decrypt(request.Token),
                                         cryptoService.Decrypt(request.Email), cryptoService.Decrypt(request.Serial));

            if (await serialService.SerialExists(serial))
            {
                throw new DuplicateException("Serial already exists");
            }

            return(await accountManager.AddSerial(serial, email, token)
                ? (AddSerialResponse) new AddSerialResponse().LogInformation(
                       $"User with email {email} added serial to their account")
                : throw new ChangeEmailException("Error occured during changing email"));
        }