public TransactionRequest(string from, string to, decimal amount, string detail, ApplicableTax tax, bool force = false) { this.FromAccount = from; this.ToAccount = to; this.Amount = amount; this.Detail = detail; this.Force = force; this.Tax = tax; }
public async Task <ActionResult <TaskResult> > SendTransactionByIDS(string from, string to, decimal amount, string auth, string detail) { if (string.IsNullOrWhiteSpace(auth)) { return(NotFound("Please specify authorization.")); } Entity fromAccount = await Entity.FindAsync(from); if (fromAccount == null) { return(NotFound("Could not find " + from)); } if (!(await fromAccount.HasPermissionWithKey(auth, "eco"))) { return(Unauthorized("You do not have permission to do that!")); } ApplicableTax tax = ApplicableTax.None; Entity toAccount = await Entity.FindAsync(to); if (toAccount == null) { return(NotFound("Could not find " + to)); } if (toAccount is Group) { tax = ApplicableTax.Corporate; } else { if (detail.ToLower().Contains("sale")) { tax = ApplicableTax.Sales; } } if (string.IsNullOrWhiteSpace(detail)) { detail = "Undefined API Call"; } TaskResult result = await new TransactionRequest(from, to, amount, detail, tax).Execute(); if (result.Succeeded) { return(Ok(result)); } else { return(NotFound(result)); } }
public static string TaxToString(ApplicableTax type) { return(type switch { ApplicableTax.None => nameof(ApplicableTax.None), ApplicableTax.Corporate => nameof(ApplicableTax.Corporate), ApplicableTax.Payroll => nameof(ApplicableTax.Payroll), ApplicableTax.CapitalGains => nameof(ApplicableTax.CapitalGains), ApplicableTax.Sales => nameof(ApplicableTax.Sales), _ => throw new ArgumentOutOfRangeException(nameof(type), type, null) });