Example #1
0
        public async Task <bool> AddPurchaseOption(PurchaseOptions purchaseOption)
        {
            try
            {
                _context.PurchaseOptions.Add(purchaseOption);
                var response = await _context.SaveChangesAsync();

                return(response >= 1);
            }
            catch (DbUpdateException ex)
            {
                throw new DbUpdateException(ex.Message);
            }
        }
Example #2
0
    public DiningRoomGUI()
    {
        this.MakeOrderEvent += this.makeOrderHandler;
        this.Activated      += this.ActivatedHandler;
        BackColor            = Color.Silver;
        Size = new Size(600, 600);
        Text = "Dining Room";
        PurchaseOptions foods  = new PurchaseOptions(this, 25, new string[] { "Arroz de Marisco : 15€", "Massa à labrador : 5€", "Prego em Prato : 5,5€" }, "Kitchen");
        PurchaseOptions drinks = new PurchaseOptions(this, 300, new string[] { "Cerveja : 1,5€", "Água : 1€", "Coca-Cola : 1,20€" }, "Bar");

        this.tables      = new Tables(this, 150, 8);
        this.orderTotal  = new OrderTotal(this, 200);
        this.readyOrders = new ReadyOrders(25, 300);
    }
Example #3
0
    //function that tests and charges if it possible to buy items
    protected override bool Charge(PurchaseOptions data)
    {
        //check if the buyer has enough cash
        if (data.buyer.cash >= products [data.index].cost)
        {
            //check if the type of purchase is delivery
            if (data.delivery)
            {
                //loop through all jobs
                for (int a = 0; a < occupations.Count; a++)
                {
                    //check if current job is a delivery job
                    if (occupations [a].delivery)
                    {
                        //check if the current job is open
                        if (occupations [a].open)
                        {
                            //setup delivery data required
                            DeliveryInfo details = new DeliveryInfo();
                            details.items      = new List <Item> ();
                            details.itemPrices = new List <float> ();
                            details.items.Add(products [data.index].data);
                            details.recipient = data.buyer;
                            details.itemPrices.Add(products [data.index].cost);
                            ((Delivery)occupations [a]).deliveryJobs.Add(details);

                            //remove cash from the buyer and add cash to this store
                            data.buyer.cash -= products [data.index].cost;
                            data.buyer.waitingForDelivery++;

                            cash += products [data.index].cost;
                            return(true);
                        }
                    }
                }
            }             //if customer is in shop check if the shop has a job that sells instore
            else if (inStore && !data.delivery)
            {
                //remove cash from the buyer and add cash to this store
                data.buyer.cash -= products [data.index].cost;
                data.buyer.inventory.Add(products [data.index].data);
                cash += products [data.index].cost;
                return(true);
            }
        }
        return(false);
    }
Example #4
0
 //function that tests and charges if it possible to buy items
 protected override bool Charge(PurchaseOptions data)
 {
     //test if the buyer can afford the current product
     if (CompareCost(houses[data.index], data.buyer))
     {
         //loop through all current occupants of purchase data and setup new house
         for (int a = 0; a < data.buyer.stats.accomodation.occupants.Count; a++)
         {
             //remove cash from every buyer equally
             data.buyer.stats.accomodation.occupants [a].cash -=
                 houses [data.index].data.initialCost / data.buyer.stats.accomodation.occupants.Count;
             houses [data.index].data.occupants.Add(data.buyer.stats.accomodation.occupants [a]);
             data.buyer.stats.accomodation.occupants [a].stats.accomodation.homeData = houses [data.index].data;
             data.buyer.stats.accomodation.occupants [a].stats.accomodation.home     = houses [data.index].gameObject;
         }
         //add purchase cost to business cash
         cash += houses [data.index].data.initialCost;
         return(true);
     }
     return(false);
 }
Example #5
0
        internal async Task <RateOptionsSubmissionResult> SubmitRateOptions()
        {
            var equipmentAmount = EquipmentAmount.AsDouble();

            if (equipmentAmount > MaxEquipmentAmount || equipmentAmount < MinEquipmentAmount)
            {
                return(RateOptionsSubmissionResult.InvalidEquipmentAmount);
            }
            var pointAmount = Points.AsInt();

            if (pointAmount > MaxPoints)
            {
                return(RateOptionsSubmissionResult.InvalidPointAmount);
            }

            //need to get max points value

            var terms            = Terms.Where(t => t.IsSelected);
            var rateCards        = RateCards.Where(r => r.IsSelected);
            var maintenanceTypes = MaintenanceTypes.Where(m => m.IsSelected);
            var purchaseOptions  = PurchaseOptions.Where(p => p.IsSelected);
            var advancePayments  = AdvancePayments.Where(a => a.IsSelected);

            _quoteBuilder.SetRateOptions(new RateOptions
            {
                CompanyName          = CompanyName,
                EquipmentAmount      = EquipmentAmount.AsDouble(),
                EquipmentDescription = EquipmentDescription,
                RateCards            = rateCards.ToList(),
                Terms            = terms.ToList(),
                MaintenanceTypes = maintenanceTypes.ToList(),
                PurchaseOptions  = purchaseOptions.ToList(),
                Points           = Points.AsInt(),
                PassThrough      = PassThrough.AsInt(),
                AdvancePayments  = advancePayments.ToList()
            });
            try
            {
                _hudProvider.DisplayProgress("Retrieving Payment Options");

                var response = await _monthlyPaymentService.GetMonthlyPayments(_quoteBuilder.GetQuote());

                if (response != null)
                {
                    if (response.ErrorStatusCode == 400)
                    {
                        return(RateOptionsSubmissionResult.UnableToRetrieveData);
                    }
                    else if (response.ErrorStatusCode == 401)
                    {
                        return(RateOptionsSubmissionResult.Unauthorized);
                    }
                    else if (response.MonthlyPayments == null || response.MonthlyPayments.Count() == 0)
                    {
                        return(RateOptionsSubmissionResult.Failure);
                    }
                    else
                    {
                        _quoteBuilder.SetMonthlyPayments(response.MonthlyPayments.ToList());
                        return(RateOptionsSubmissionResult.Success);
                    }
                }
                return(RateOptionsSubmissionResult.Failure);
            }
            catch (Exception ex)
            {
                return(RateOptionsSubmissionResult.Failure);                //tell view to pop alert
            }
            finally
            {
                _hudProvider.Dismiss();
            }
        }
 public PurchaseController(IOptions <APIOptions> apiOptionsAccessor, IOptions <PurchaseOptions> purchaseOptionsAccessor)
 {
     _apiOptions      = apiOptionsAccessor.Value;
     _purchaseOptions = purchaseOptionsAccessor.Value;
     _broker          = new PurchaseBroker();
 }
Example #7
0
 protected abstract bool Charge(PurchaseOptions data);
Example #8
0
    //==============IMPORTANT========================
    //the functions below are all virtual/abstract functions
    //that classes that inherit from business require to
    //work with other systems implemented within humanLife
    //most of the functions have two types an abstract and virtual
    //this is to get around most derived functions not being called

    public virtual bool Buy(PurchaseOptions data)
    {
        return(Charge(data));
    }
Example #9
0
 protected override bool Charge(PurchaseOptions data)
 {
     return(false);
 }