Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
        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));
            }
        }
Exemplo n.º 3
0
 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)
     });