Esempio n. 1
0
 public ErrorMonad <int> Save(Customer customer)
 {
     if (Successful(customer))
     {
         return(ErrorMonad <int> .Valid(customer.CustomerId));
     }
     else
     {
         return(ErrorMonad <int> .Error("Failed to Save Customer"));
     }
 }
Esempio n. 2
0
 public ErrorMonad <U> AndThen <U>(Func <TaskFactory, ErrorMonad <U> > step)
 {
     if (_error != null)
     {
         return(ErrorMonad <U> .Error(_error));
     }
     else
     {
         return(step(_value));
     }
 }
Esempio n. 3
0
 public static Customer Create(string name, string phoneNumber)
 {
     if (ValidPhoneNumber.IsMatch(phoneNumber))
     {
         return(ErrorMonad <Customer> .Valid(Customer.Create(name, phoneNumber)));
     }
     else
     {
         return(ErrorMonad <Customer> .Error("Invalid PhoneNumber"));
     }
 }
Esempio n. 4
0
 public static ErrorMonad <Customer> Create(string name, string phoneNumber)
 {
     if (ValidPhoneNumber.IsMatch(phoneNumber))
     {
         return(ErrorMonad <Customer> .Valid(new Customer(name, phoneNumber)));
     }
     else
     {
         return(ErrorMonad <Customer> .Error("THERE WAS AN ERRORRR"));
     }
 }