private static ITry <ShoppingListWithItems, AddFoodstuffsError> Process(ApiResult <AddFoodstuffsToShoppingListResponse> response) =>
 response.Match(
     s => Try.Success <ShoppingListWithItems, AddFoodstuffsError>(ToShoppingList(s)),
     e => Try.Error <ShoppingListWithItems, AddFoodstuffsError>(e.Message.Match(
                                                                    "Item already added.", _ => AddFoodstuffsError.FoodstuffAlreadyAdded
                                                                    )),
     noConn => throw new NotImplementedException()
Example #2
0
 private static ITry <Unit, SignUpError[]> Success() =>
 Try.Success <Unit, SignUpError[]>(Unit.Value);
Example #3
0
 private static ITry <Unit, SignUpError[]> Error(IEnumerable <SignUpError> errors) =>
 Try.Error <Unit, SignUpError[]>(errors.ToArray());
Example #4
0
 private static ITry <IAccount, SignInError> Success(IAccount a) =>
 Try.Success <IAccount, SignInError>(a);
Example #5
0
 private static ITry <IAccount, SignInError> Error(SignInError e) =>
 Try.Error <IAccount, SignInError>(e);
 public static ITry <T, E> ToTry <T, E>(this bool b, Func <Unit, T> ifTrue, Func <Unit, E> ifFalse)
 {
     return(b ? Try.Success <T, E>(ifTrue(Unit.Value)) : Try.Error <T, E>(ifFalse(Unit.Value)));
 }