private UserActionResult ToUserActionResult(ITry <Unit, SignInError> t) =>
 t.Match(
     s => UserActionResult.Success(),
     e => e.Match(
         SignInError.InvalidCredentials, _ => UserActionResult.Error(UserMessages.InvalidCredentials()),
         SignInError.NoConnection, _ => UserActionResult.Error(UserMessages.NoConnection())
         )
     );
Esempio n. 2
0
 private UserActionResult ToUserActionResult(ITry <Unit, SignUpError[]> t) =>
 t.Match(
     s => UserActionResult.Success(),
     e => e.First().Match(
         SignUpError.NoConnection, _ => UserActionResult.Error(UserMessages.NoConnection()),
         SignUpError.InvalidEmail, _ => Email.Invalidate().Pipe(u => UserActionResult.Error()),
         SignUpError.PasswordTooShort, _ => Password.Invalidate().Pipe(u => UserActionResult.Error()),
         SignUpError.AccountAlreadyExists, _ => UserActionResult.Error(UserMessages.AccountAlreadyExists())
         )
     );
Esempio n. 3
0
        public static UserActionResult ToUserActionResult(this IEnumerable <Exception> exceptions)
        {
            var message = exceptions.Select(e => e.Message).Aggregate((s1, s2) => $"{s1}{Environment.NewLine}{s2}");

            return(UserActionResult.Error(new UserMessage("Error", message)));
        }