Exemple #1
0
        public async Task <Maybe <RegisteredUserResponse> > Register(RegisterUserRequest user)
        {
            var isUserExist = await _finder.FindByEmail(user.Email);

            if (isUserExist.HasError)
            {
                var createdUser = await _writer.SaveAsync(new User
                {
                    Id    = Guid.NewGuid(),
                    Email = user.Email,
                });

                return(new Maybe <RegisteredUserResponse>(new RegisteredUserResponse
                {
                    Id = createdUser.Id,
                    Email = createdUser.Email,
                }));
            }

            return(new Maybe <RegisteredUserResponse>("User with specified email already exists."));
        }