public ActionResult Edit(int id) { Option <Customer> customer = _database.GetById(id); if (customer.HasNoValue) { return(HttpNotFound()); } return(View(customer.Value)); }
public string RefillBalance(int customerId, decimal moneyAmount) { Result <MoneyToCharge> moneyToCharge = MoneyToCharge.Create(moneyAmount); Result <CustomerManagement> customer = _database.GetById(customerId).ToResult("Customer is not found"); return(Result.Combine(moneyToCharge, customer) .OnSuccess(() => customer.value.AddBalance(moneyToCharge.value)) .OnSuccess(() => _paymentGateway.ChargePayment(customer.value.BillingInfo, moneyToCharge.value)) .OnSuccess( () => _database.Save(customer.value) .OnFailure(() => _paymentGateway.RollbackLastTransaction())) .OnBoth(result => Log(result)) .OnBoth(result => result.isSuccues ? "OK" : result.Error)); }