Exemplo 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"));
     }
 }
Exemplo 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));
     }
 }
Exemplo 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"));
     }
 }
Exemplo 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"));
     }
 }