Ejemplo n.º 1
0
        public async Task <bool> Process(int saleOrderId)
        {
            SaleOrder = await Tenant.SaleOrders
                        .WhereId(saleOrderId)
                        .IncludeStore()
                        .IncludeSaleProducts()
                        .IncludePaymentMethodsAndFees()
                        .SingleOrDefaultAsync();

            if (SaleOrder == null || SaleOrder.Confirmed || SaleOrderIsPending())
            {
                return(false);
            }

            ProductConsumption = new ProductConsumption(Tenant, SaleOrder);
            if (!await ProductConsumption.Confirm())
            {
                return(false);
            }

            Billing = new SaleBilling(Tenant, SaleOrder);
            Billing.Confirm();

            SaleOrder.ConfirmationDate = DateTime.UtcNow;

            await Tenant.SaveChangesAsync();

            return(true);
        }
Ejemplo n.º 2
0
        public async Task <bool> ProcessDelivery(int rentContractId)
        {
            RentContract = await Tenant.RentContracts
                           .WhereId(rentContractId)
                           .IncludeStore()
                           .IncludeRentedProducts()
                           .IncludePaymentMethodsAndFees()
                           .SingleOrDefaultAsync();

            if (RentContract == null || RentContract.Confirmed || RentContractIsPending())
            {
                return(false);
            }

            ProductConsumption = new ProductConsumption(Tenant, RentContract);
            if (!await ProductConsumption.Confirm())
            {
                return(false);
            }

            Billing = new RentBilling(Tenant, RentContract);
            Billing.Confirm();

            RentContract.ConfirmationDate = DateTime.UtcNow;

            await Tenant.SaveChangesAsync();

            return(true);
        }