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);
        }
        public async Task <bool> Revert(int rentContractId)
        {
            RentContract = await Tenant.RentContracts
                           .WhereId(rentContractId)
                           .IncludeStore()
                           .IncludeRentedProducts()
                           .IncludeRentIncomes()
                           .SingleOrDefaultAsync();

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

            ProductConsumption = new ProductConsumption(Tenant, RentContract);
            await ProductConsumption.Revert();

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

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

            RentContract.ConfirmationDate = null;
            RentContract.DateOfReturn     = null;

            await Tenant.SaveChangesAsync();

            return(true);
        }