Esempio n. 1
0
 public void GenerateOrder()
 {
     CurrentOrder currentOrder = new CurrentOrder();
     CharacterPrep curChar = GameController.current.currentCharacter;
     curChar.OrganizeProperties();
     List<OrderItem> generatedOrderItems = new List<OrderItem>();
     for (int i = 0; i < curChar.possibleOrders.Length; i++){
         if (Random.Range(0, curChar.orderModifier + 1) < curChar.orderModifier / 2)
             generatedOrderItems.Add(curChar.possibleOrders[i]);
     }
     if(generatedOrderItems.Count > 0){
         List<string> currentOrderExtras = new List<string>();
         List<string> currentOrderNots = new List <string>();
         for (int i = 0; i < ingridientNames.Length; i++){
             ExtrasAddorRemove(ingridientNames[i], curChar.orderModifiersEx, currentOrderExtras);
             ExtrasAddorRemove(ingridientNames[i], curChar.orderModifiersNo, currentOrderNots);
         }
         currentOrder.orderItems = new OrderItem[generatedOrderItems.Count];
         for (int i = 0; i < generatedOrderItems.Count; i++){
             currentOrder.orderItems[i] = generatedOrderItems[i];
         }
         if (currentOrderExtras.Count > 0){
             int j = 0;
             currentOrder.extras = new string[currentOrderExtras.Count];
             currentOrder.orderItems[j].attributedExtras = new List<string>();
             for (int i = 0; i < currentOrderExtras.Count; i++){
                 currentOrder.extras[i] = currentOrderExtras[i];
                 currentOrder.orderItems[j].attributedExtras.Add(currentOrderExtras[i]);
                 if(Random.Range(0, 2) < 1 && j + 1 < generatedOrderItems.Count)
                     j++;
             }
         }
         if (currentOrderNots.Count > 0){
             currentOrder.nots = new string[currentOrderNots.Count];
             for (int i = 0; i < currentOrderNots.Count; i++){
                 currentOrder.nots[i] = currentOrderNots[i];
             }
         }
         if(curChar.extraCondiment){
             for (int i = 0; i < condimentNames.Length; i++){
                 if(Random.Range(0, 2) < 1)
                     currentOrder.extraCondiment = condimentNames[i];
             }
         }
     }
     currentOrder.fries = curChar.friesSize[Random.Range(0, curChar.friesSize.Length)];
     currentOrder.drinkType = curChar.drinkTypes[Random.Range(0, curChar.drinkTypes.Length)];
     currentOrder.drinkSize = curChar.drinkSizes[Random.Range(0, curChar.drinkSizes.Length)];
     CookingController.current.OrderInitiate(currentOrder);
 }
        public void SetOrder(Order order, string option, Character orderGiver, bool speak)
        {
            if (character.IsDead)
            {
#if DEBUG
                DebugConsole.ThrowError("Attempted to set an order for a dead character");
#else
                return;
#endif
            }
            ClearIgnored();
            CurrentOrder = CreateObjective(order, option, orderGiver, isAutonomous: false);
            if (CurrentOrder == null)
            {
                // Recreate objectives, because some of them may be removed, if impossible to complete (e.g. due to path finding)
                CreateAutonomousObjectives();
            }
            else
            {
                // This should be redundant, because all the objectives are reset when they are selected as active.
                CurrentOrder.Reset();
                if (speak)
                {
                    character.Speak(TextManager.Get("DialogAffirmative"), null, 1.0f);
                    if (speakRoutine != null)
                    {
                        CoroutineManager.StopCoroutines(speakRoutine);
                    }
                    speakRoutine = CoroutineManager.InvokeAfter(() =>
                    {
                        if (GameMain.GameSession == null || Level.Loaded == null)
                        {
                            return;
                        }
                        if (CurrentOrder != null && character.SpeechImpediment < 100.0f)
                        {
                            if (CurrentOrder is AIObjectiveRepairItems repairItems && repairItems.Targets.None())
                            {
                                character.Speak(TextManager.Get("DialogNoRepairTargets"), null, 3.0f, "norepairtargets");
                            }
                            else if (CurrentOrder is AIObjectiveChargeBatteries chargeBatteries && chargeBatteries.Targets.None())
                            {
                                character.Speak(TextManager.Get("DialogNoBatteries"), null, 3.0f, "nobatteries");
                            }
                            else if (CurrentOrder is AIObjectiveExtinguishFires extinguishFires && extinguishFires.Targets.None())
                            {
                                character.Speak(TextManager.Get("DialogNoFire"), null, 3.0f, "nofire");
                            }
Esempio n. 3
0
        public ActionResult Create([Bind(Include = "Id,Country,City,FirstDay,LastDay")] CurrentOrder currentOrder)
        {
            if (ModelState.IsValid)
            {
                if (db.CurrentOrders != null)
                {
                    db.CurrentOrders.Remove(db.CurrentOrders.First());
                    db.SaveChanges();
                }
                db.CurrentOrders.Add(currentOrder);
                db.SaveChanges();
                return(RedirectToAction("Index", "Places"));
            }

            return(ViewBag.Message("Ошибка"));
        }
        public IActionResult Delete(int id)
        {
            // Check if the data matches the Model
            CurrentOrder currentOrder = _context.CurrentOrder.Single(c => c.CurrentOrderId == id);

            // Return 404 if not found
            if (currentOrder == null)
            {
                return(NotFound());
            }
            // Remove method
            _context.CurrentOrder.Remove(currentOrder);
            // Save table after removal
            _context.SaveChanges();
            return(Ok(currentOrder));
        }
Esempio n. 5
0
        private void ReloadOrder(OrderShippingStatus previousShippingStatus, bool SendEmail = true)
        {
            CurrentOrder.EvaluateCurrentShippingStatus();
            HccApp.OrderServices.Orders.Update(CurrentOrder);
            var context = new OrderTaskContext
            {
                Order  = CurrentOrder,
                UserId = CurrentOrder.UserID
            };

            context.Inputs.Add("hcc", "PreviousShippingStatus", previousShippingStatus.ToString());

            Workflow.RunByName(context, WorkflowNames.ShippingChanged);

            LoadOrder();
        }
        private void SavePaymentInfo()
        {
            var payManager = new OrderPaymentManager(CurrentOrder, HccApp);

            payManager.ClearAllNonStoreCreditTransactions();

            // Don't add payment info if gift cards or points cover the entire order.
            var total = CurrentOrder.TotalGrandAfterStoreCredits(HccApp.OrderServices);

            if (total <= 0 && !CurrentOrder.IsRecurring)
            {
                return;
            }

            if (rbCreditCard.Checked)
            {
                var creditCardData = ucCreditCardInput.GetCardData();
                if (!CurrentOrder.IsRecurring)
                {
                    payManager.CreditCardAddInfo(creditCardData, total);
                }
                else
                {
                    payManager.RecurringSubscriptionAddCardInfo(creditCardData);
                }
            }
            else if (rbPurchaseOrder.Checked)
            {
                payManager.PurchaseOrderAddInfo(txtPurchaseOrder.Text.Trim(), total);
            }
            else if (rbCompanyAccount.Checked)
            {
                payManager.CompanyAccountAddInfo(txtAccountNumber.Text.Trim(), total);
            }
            else if (rbCheck.Checked)
            {
                payManager.OfflinePaymentAddInfo(total, Localization.GetFormattedString("CustomerPayByCheck"));
            }
            else if (rbTelephone.Checked)
            {
                payManager.OfflinePaymentAddInfo(total, Localization.GetString("CustomerPayByPhone"));
            }
            else if (rbCashOnDelivery.Checked)
            {
                payManager.OfflinePaymentAddInfo(total, Localization.GetString("CustomerPayCod"));
            }
        }
Esempio n. 7
0
        public void UpdateObjectives(float deltaTime)
        {
            if (CurrentOrder != null)
            {
#if DEBUG
                // Note: don't automatically remove orders here. Removing orders needs to be done via dismissing.
                if (CurrentOrder.IsCompleted)
                {
                    DebugConsole.NewMessage($"{character.Name}: ORDER {CurrentOrder.DebugTag} IS COMPLETED. CURRENTLY ALL ORDERS SHOULD BE LOOPING.", Color.Red);
                }
                else if (!CurrentOrder.CanBeCompleted)
                {
                    DebugConsole.NewMessage($"{character.Name}: ORDER {CurrentOrder.DebugTag}, CANNOT BE COMPLETED.", Color.Red);
                }
#endif
                CurrentOrder.Update(deltaTime);
            }
            if (WaitTimer > 0)
            {
                WaitTimer -= deltaTime;
                return;
            }
            for (int i = 0; i < Objectives.Count; i++)
            {
                var objective = Objectives[i];
                if (objective.IsCompleted)
                {
#if DEBUG
                    DebugConsole.NewMessage($"{character.Name}: Removing objective {objective.DebugTag}, because it is completed.", Color.LightBlue);
#endif
                    Objectives.Remove(objective);
                }
                else if (!objective.CanBeCompleted)
                {
#if DEBUG
                    DebugConsole.NewMessage($"{character.Name}: Removing objective {objective.DebugTag}, because it cannot be completed.", Color.Red);
#endif
                    Objectives.Remove(objective);
                    FailedAutonomousObjectives = true;
                }
                else
                {
                    objective.Update(deltaTime);
                }
            }
            GetCurrentObjective();
        }
 protected void btnAddCoupon_Click(object sender, EventArgs e)
 {
     Page.Validate("vgCoupon");
     if (Page.IsValid)
     {
         var couponResult = CurrentOrder.AddCouponCode(txtCoupon.Text.Trim());
         if (couponResult == false)
         {
             ucMessageBox.ShowError(Localization.GetString("InvalidCoupon"));
         }
         else
         {
             HccApp.OrderServices.Orders.Update(CurrentOrder);
         }
         LoadOrder();
     }
 }
Esempio n. 9
0
        protected void Delete_Click(object sender, EventArgs e)
        {
            MessageUserControl.TryRun(() =>
            {
                var poid = Convert.ToInt32((CurrentOrderGridView.Rows[0].FindControl("PurchaseOrderID") as HiddenField).Value);
                if (poid == 0)
                {
                    throw new Exception("empty");
                }
                FinalOrder purchase              = new FinalOrder();
                purchase.PurchaseOrderID         = Convert.ToInt32((CurrentOrderGridView.Rows[0].FindControl("PurchaseOrderID") as HiddenField).Value);
                purchase.VendorID                = int.Parse(VendorDropDown.SelectedValue);
                purchase.Subtotal                = decimal.Parse(Subtotal.Text.Substring(1));
                purchase.GST                     = decimal.Parse(GST.Text.Substring(1));
                List <CurrentOrder> orderDetails = new List <CurrentOrder>();

                foreach (GridViewRow row in CurrentOrderGridView.Rows)
                {
                    var partid = row.FindControl("PartID") as Label;
                    var qty    = row.FindControl("Qty") as TextBox;
                    var price  = row.FindControl("Price") as TextBox;

                    if (partid != null)
                    {
                        var details    = new CurrentOrder();
                        details.PartID = int.Parse(partid.Text);
                        details.Qty    = int.Parse(qty.Text);
                        details.Price  = decimal.Parse(price.Text);
                        orderDetails.Add(details);
                    }
                    else
                    {
                        throw new Exception("Empty");
                    }
                }

                var controller = new PurchasingController();
                controller.DeleteCurrentOrder(purchase);
                OrderDetailsPanel.Enabled    = false;
                OrderDetailsPanel.Visible    = false;
                VendorDropDown.SelectedIndex = 0;
                VendorName.Text = "";
                Location.Text   = "";
                Phone.Text      = "";
            }, "Success", "Order deleted");
        }
Esempio n. 10
0
        protected void Update_Click(object sender, EventArgs e)
        {
            MessageUserControl.TryRun(() =>
            {
                CalculateTotals();

                FinalOrder purchase            = new FinalOrder();
                purchase.PurchaseOrderID       = Convert.ToInt32((CurrentOrderGridView.Rows[0].FindControl("PurchaseOrderID") as HiddenField).Value);
                purchase.PurchaseOrderDetailID = Convert.ToInt32((CurrentOrderGridView.Rows[0].FindControl("PurchaseOrderDetailID") as HiddenField).Value);
                purchase.VendorID = int.Parse(VendorDropDown.SelectedValue);
                purchase.Subtotal = decimal.Parse(Subtotal.Text.Substring(1));
                purchase.GST      = decimal.Parse(GST.Text.Substring(1));
                List <CurrentOrder> orderDetails = new List <CurrentOrder>();

                foreach (GridViewRow row in CurrentOrderGridView.Rows)
                {
                    var partid = row.FindControl("PartID") as Label;
                    var qty    = row.FindControl("Qty") as TextBox;
                    var price  = row.FindControl("Price") as TextBox;
                    if (int.Parse(qty.Text) < 0)
                    {
                        throw new Exception("Quantity cannot be a negative number");
                    }
                    if (decimal.Parse(price.Text) <= 0)
                    {
                        throw new Exception("Price cannot be a negative number");
                    }
                    if (partid != null)
                    {
                        var details    = new CurrentOrder();
                        details.PartID = int.Parse(partid.Text);
                        details.Qty    = int.Parse(qty.Text);
                        details.Price  = decimal.Parse(price.Text);
                        orderDetails.Add(details);
                    }
                    else
                    {
                        throw new Exception("Empty");
                    }
                }

                var controller        = new PurchasingController();
                purchase.OrderDetails = orderDetails;
                controller.UpdateCurrentOrder(purchase);
            }, "Sucess", "Order updated.");
        }
Esempio n. 11
0
 protected void btnAddCoupon_Click(object sender, EventArgs e)
 {
     Page.Validate("vgCoupon");
     if (Page.IsValid)
     {
         var couponResult = CurrentOrder.AddCouponCode(txtCoupon.Text.Trim());
         if (couponResult == false)
         {
             ucMessageBox.ShowError("Coupon does not apply or already exists.");
         }
         else
         {
             HccApp.OrderServices.Orders.Update(CurrentOrder);
         }
         LoadOrder();
     }
 }
Esempio n. 12
0
 private void removeOD_btn_Click(object sender, EventArgs e)
 {
     try
     {
         OrderDetail od = bdsDetails.Current as OrderDetail;
         if (od == null)
         {
             MessageBox.Show("请选择一个订单项进行删除");
             return;
         }
         CurrentOrder.removeOD(od);
         bdsDetails.ResetBindings(false);
     }
     catch (Exception e2)
     {
         MessageBox.Show(e2.Message);
     }
 }
Esempio n. 13
0
        /// <summary>
        /// Inserts an order
        /// </summary>
        /// <param name="order">Order</param>
        public virtual void InsertOrder(CurrentOrder order)
        {
            if (order == null)
            {
                throw new ArgumentNullException(nameof(order));
            }

            _currentOrderRepository.Insert(order);

            // update table state
            var table = _tableRepository.GetById(order.TableId);

            table.State = TableState.Serving;
            _tableRepository.Update(table);

            //event notification
            _eventPublisher.EntityInserted(order);
        }
Esempio n. 14
0
        public void LifeTime_Tick(Object sender, EventArgs e)
        {
            LifeForm lf = new LifeForm(Coloni, Par);

            this.NewColoni(Coloni, CurrentOrder, Par, Stat); //create start coloni if coloni.count == 0
            CurrentOrder.UpdateOrder(Coloni);                //<<

            lf.Growing(Coloni);                              //growing for everybody
            lf.Search(Coloni, CurrentOrder);                 //search target to move
            lf.Move(Coloni);
            CurrentOrder.UpdateOrder(Coloni);                //<<

            lf.Sex(Coloni);
            lf.Death(Coloni, Stat);
            DrawObject.DrawLf(Coloni, Par);
            lf.RemoveBody(Coloni);
            CurrentOrder.UpdateOrder(Coloni); //<<
            lf.Born(Coloni, Stat);
        }
Esempio n. 15
0
        private AIObjective GetCurrentObjective()
        {
            var previousObjective = CurrentObjective;
            var firstObjective    = Objectives.FirstOrDefault();

            if (CurrentOrder != null && firstObjective != null && CurrentOrder.GetPriority(this) > firstObjective.GetPriority(this))
            {
                CurrentObjective = CurrentOrder;
            }
            else
            {
                CurrentObjective = firstObjective;
            }
            if (previousObjective != CurrentObjective)
            {
                CurrentObjective?.OnSelected();
            }
            return(CurrentObjective);
        }
Esempio n. 16
0
        async void CreateNewOrder_Clicked(object sender, EventArgs e)
        {
            if (selectedList.Count == 0)
            {
                await DisplayAlert("Nothing Selected", "You need to select a customer to create or add to an order!", "Ok");
            }
            else
            {
                if (_currentOrder.Count > 0)
                {
                    if (await DisplayAlert("Warning!", "Do you want to add to the current order or create new order?", "New", "Add"))
                    {
                        await _connection.DeleteAllAsync <CurrentOrder>();

                        foreach (var item in selectedList)
                        {
                            CurrentOrder order = new CurrentOrder()
                            {
                                Id         = item.Id,
                                Name       = item.Name,
                                CoffeeSize = item.CoffeeSize,
                                CoffeeType = item.CoffeeType,
                                Paid       = false
                            };
                            await _connection.InsertAsync(order);

                            _currentOrder.Add(order);
                        }
                        selectedList.Clear();
                        await Shell.Current.GoToAsync("//CurrentOrderPage");
                    }
                    else
                    {
                        await AddToOrder();
                    }
                }
                else
                {
                    await AddToOrder();
                }
            }
        }
        public async Task <IActionResult> AddOrder([FromRoute] int id, [FromBody] Order order)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (!ClientExists(id))
            {
                return(NotFound());
            }

            order.ClientId = id;
            var newOrder = new CurrentOrder(order);

            _context.CurrentOrders.Add(newOrder);
            await _context.SaveChangesAsync();

            return(NoContent());
        }
Esempio n. 18
0
 public void DeleteOrder()
 {
     if (!(CurrentOrder is null))
     {
         try
         {
             CurrentOrder.Delete();
         }
         catch (Exception e)
         {
             MessageBox.Show(e.Message);
         }
         Orders.Remove(CurrentOrder);
         CurrentOrder = null;
     }
     if (Orders.Count() > 0)
     {
         CurrentOrder = Orders.Last();
     }
 }
Esempio n. 19
0
        private void btnAddItem_Click(object sender, EventArgs e)
        {
            FormDetailEdit formItemEdit = new FormDetailEdit(new OrderDetail());

            try {
                if (formItemEdit.ShowDialog() == DialogResult.OK)
                {
                    uint index = 0;
                    if (CurrentOrder.Details.Count != 0)
                    {
                        index = CurrentOrder.Details.Max(i => i.Index) + 1;
                    }
                    formItemEdit.Detail.Index = index;
                    CurrentOrder.AddItem(formItemEdit.Detail);
                    bdsDetails.ResetBindings(false);
                }
            }catch (Exception e2) {
                MessageBox.Show(e2.Message);
            }
        }
Esempio n. 20
0
        private AIObjective GetCurrentObjective()
        {
            var previousObjective = CurrentObjective;
            var firstObjective    = Objectives.FirstOrDefault();

            if (CurrentOrder != null && firstObjective != null && CurrentOrder.GetPriority() > firstObjective.GetPriority())
            {
                CurrentObjective = CurrentOrder;
            }
            else
            {
                CurrentObjective = firstObjective;
            }
            if (previousObjective != CurrentObjective)
            {
                previousObjective?.OnDeselected();
                CurrentObjective?.OnSelected();
                GetObjective <AIObjectiveIdle>().SetRandom();
            }
            return(CurrentObjective);
        }
Esempio n. 21
0
        public AddPersonPage(CurrentOrder currentOrderCustomer, bool update)
        {
            InitializeComponent();
            GetConnection();
            customer = new Customer()
            {
                Id         = currentOrderCustomer.Id,
                Name       = currentOrderCustomer.Name,
                CoffeeSize = currentOrderCustomer.CoffeeSize,
                CoffeeType = currentOrderCustomer.CoffeeType
            };

            this.update  = update;
            currentOrder = currentOrderCustomer;


            // Fill fields with info
            name.Text = currentOrderCustomer.Name;
            coffeetype.SelectedItem = currentOrderCustomer.CoffeeType;
            coffeesize.SelectedItem = currentOrderCustomer.CoffeeSize;
        }
Esempio n. 22
0
        public virtual void Tick()
        {
            if (underConstruction)
            {
                if (!constructionPaused)
                {
                    if (!billOfMaterials.HasMats)
                    {
                        billOfMaterials.Tick();
                    }
                    else
                    {
                        if (DecreaseTime())
                        {
                            underConstruction = false;
                            Messages.Message("AssemblyLineConstructionFinished".Translate(this.label), MessageSound.Benefit);
                        }
                    }
                }
            }
            else
            {
                UpgradeManager.Tick();

                if (CurrentOrder != null)
                {
                    if (CurrentOrder.DesiresToWork)
                    {
                        CurrentOrder.Tick();
                    }
                    else
                    {
                        if (orderStack.Count > 1 && orderStack.Any((Order o) => o.DesiresToWork))
                        {
                            OrderStack.FinishOrderAndGetNext(CurrentOrder);
                        }
                    }
                }
            }
        }
Esempio n. 23
0
        protected void btnUpdateQuantities_Click(object sender, EventArgs e)
        {
            var gridView = CurrentOrder.IsRecurring ? gvSubscriptions : gvItems;

            foreach (GridViewRow row in gridView.Rows)
            {
                if (row.RowType != DataControlRowType.DataRow)
                {
                    continue;
                }

                var itemId = (long)gridView.DataKeys[row.RowIndex].Value;
                var txtQty = row.FindControl("txtQty") as TextBox;

                var li       = CurrentOrder.GetLineItem(itemId);
                var quantity = int.Parse(txtQty.Text.Trim());

                var opResult = HccApp.OrderServices.OrdersUpdateItemQuantity(itemId, quantity, CurrentOrder);
                if (!string.IsNullOrEmpty(opResult.Message))
                {
                    ucMessageBox.ShowError(opResult.Message);
                }
            }

            var result = HccApp.CheckForStockOnItems(CurrentOrder);

            if (!result.Success)
            {
                ucMessageBox.ShowWarning(result.Message);
            }

            HccApp.CalculateOrderAndSave(CurrentOrder);

            var handler = OrderEdited;

            if (handler != null)
            {
                handler(this, EventArgs.Empty);
            }
        }
Esempio n. 24
0
        public void SetOrder(Order order, string option, Character orderGiver)
        {
            if (character.IsDead)
            {
#if DEBUG
                DebugConsole.ThrowError("Attempted to set an order for a dead character");
#else
                return;
#endif
            }
            ClearIgnored();
            CurrentOrder = CreateObjective(order, option, orderGiver, isAutonomous: false);
            if (CurrentOrder == null)
            {
                // Recreate objectives, because some of them may be removed, if impossible to complete (e.g. due to path finding)
                CreateAutonomousObjectives();
            }
            else
            {
                CurrentOrder.Reset();
            }
        }
Esempio n. 25
0
        public OrderReview OrderReviewVm(int id, string userName)
        {
            Customer     customer     = Context.Customers.FirstOrDefault(cust => cust.User.UserName == userName);
            CurrentOrder currentOrder = Context.CurrentOrders.FirstOrDefault(order => order.Buyer.Id == customer.Id);

            Address   delAddress   = Context.Addresses.Find(id);
            AddressVM delAddressVm = Mapper.Map <Address, AddressVM>(delAddress);


            IEnumerable <Item>         products   = currentOrder.Products;
            IEnumerable <BuyProductVm> productVms = Mapper.Map <IEnumerable <Item>, IEnumerable <BuyProductVm> >(products);


            OrderReview vm = new OrderReview()
            {
                DeliveryAddress = delAddressVm,
                BuyProductVms   = productVms,
                OrderPrice      = currentOrder.OrderPrice
            };

            return(vm);
        }
Esempio n. 26
0
        public void  CreateOrder(ConfirmOrder bind, string userName)
        {
            Customer     customer     = Context.Customers.FirstOrDefault(cust => cust.User.UserName == userName);
            CurrentOrder currentOrder = Context.CurrentOrders.FirstOrDefault(order1 => order1.Buyer.Id == customer.Id);

            Address delAddress = Context.Addresses.Find(bind.AddressId);

            OrderAddress orderAddress = new OrderAddress()
            {
                Id          = delAddress.Id,
                City        = delAddress.City,
                PostCode    = delAddress.PostCode,
                PhoneNumber = delAddress.PhoneNumber,
                Streat      = delAddress.Streat
            };

            Context.OrderAddresses.Add(orderAddress);
            Context.SaveChanges();


            IEnumerable <Item> products = currentOrder.Products;

            Order order = new Order()
            {
                Address    = orderAddress,
                Buyer      = customer,
                Status     = Models.Enums.Status.Active,
                OrderDate  = DateTime.Now,
                OrderPrice = currentOrder.OrderPrice,
                Products   = products.ToList()
            };

            //          delAddress.Orders.Add(order);

            Context.Orders.Add(order);
            Context.CurrentOrders.Remove(currentOrder);

            Context.SaveChanges();
        }
Esempio n. 27
0
        private void button_AddDetail_Click(object sender, EventArgs e)
        {
            DetailEditForm detailEditForm = new DetailEditForm(new OrderDetail());

            try
            {
                if (detailEditForm.ShowDialog() == DialogResult.OK)
                {
                    uint index = 0;
                    if (CurrentOrder.OrderDetails.Count != 0)
                    {
                        index = CurrentOrder.OrderDetails.Max(i => i.Index) + 1;
                    }
                    detailEditForm.Detail.Index = index;
                    CurrentOrder.AddItem(detailEditForm.Detail);
                    bdsDetails.ResetBindings(false);
                }
            }
            catch (Exception e2)
            {
                MessageBox.Show(e2.Message);
            }
        }
Esempio n. 28
0
        // Ritar ut en välkomstskärm
        public void StartOrder()
        {
            // För varje gång som en ny order startas eller som programmet avslutas så nollställs alla orderparametrar
            CurrentOrder.Clear();
            pizzas.Clear();
            salads.Clear();
            pastas.Clear();
            drinks.Clear();
            totalPrice = 0;


            while (correctKey == false)
            {
                Console.Clear();
                Console.WriteLine("Hej och välkommen till Pizza palatset. \nKlicka på Enter för att påbörja din beställning.");
                key = Console.ReadKey(true).KeyChar;
                if (key == 13)
                {
                    DrawFoodMenu();
                    correctKey = true;
                }
            }
        } // end StartOrder();
        public IActionResult Post(int id, [FromBody] ProductOrder productOrder)
        {
            // Check to see if the data matches the model
            if (!ModelState.IsValid)
            {
                // return 404
                return(BadRequest(ModelState));
            }
            // Check DB to ensure referenced tables exist
            CurrentOrder currentOrder = _context.CurrentOrder.Single(co => co.CurrentOrderId == id);
            Product      Product      = _context.Product.Single(p => p.ProductId == productOrder.ProductId);

            // Return 404 if null
            if (currentOrder == null || Product == null)
            {
                return(NotFound());
            }
            // Add order to the table
            _context.ProductOrder.Add(productOrder);
            // Save the changes
            _context.SaveChanges();
            // Create current order method
            return(CreatedAtRoute("GetSingleProduct", new { id = productOrder.CurrentOrderId }));
        }
        private void LoadOrder()
        {
            // Header
            OrderNumberField.Text = CurrentOrder.OrderNumber;
            TimeOfOrderField.Text =
                TimeZoneInfo.ConvertTimeFromUtc(CurrentOrder.TimeOfOrderUtc, HccApp.CurrentStore.Settings.TimeZone)
                .ToString();

            // Fraud Score Display
            if (CurrentOrder.FraudScore < 0)
            {
                lblFraudScore.Text = "No Fraud Score Data";
            }
            if (CurrentOrder.FraudScore >= 0 && CurrentOrder.FraudScore < 3)
            {
                lblFraudScore.Text = CurrentOrder.FraudScore + "<span class=\"fraud-low\"><strong>low risk</strong></span>";
            }
            if (CurrentOrder.FraudScore >= 3 && CurrentOrder.FraudScore <= 5)
            {
                lblFraudScore.Text = "<span class=\"fraud-medium\"><strong>medium risk</strong></span>";
            }
            if (CurrentOrder.FraudScore > 5)
            {
                lblFraudScore.Text = "<span class=\"fraud-high\"><strong>high risk</strong></span>";
            }

            // Billing
            lblBillingAddress.Text = CurrentOrder.BillingAddress.ToHtmlString();

            //Email
            ltEmailAddress.Text = MailServices.MailToLink(CurrentOrder.UserEmail, "Order " + CurrentOrder.OrderNumber,
                                                          CurrentOrder.BillingAddress.FirstName + ",");

            // Shipping
            if (CurrentOrder.HasShippingItems)
            {
                lblShippingAddress.Text = CurrentOrder.ShippingAddress.ToHtmlString();
            }
            else
            {
                lblShippingAddress.Text = "Non-shipping order";
            }

            //Items
            ucOrderItems.Rebind();

            // Instructions
            if (!string.IsNullOrWhiteSpace(CurrentOrder.Instructions))
            {
                pnlInstructions.Visible = true;
                lblInstructions.Text    =
                    CurrentOrder.Instructions.Replace("\r\n", "<br />").Replace("\r", "<br />").Replace("\n", "<br />");
            }


            // Totals
            litTotals.Text = CurrentOrder.TotalsAsTable(HccApp.CurrentRequestContext.MainContentCulture);

            // Coupons
            CouponField.Text = string.Empty;
            for (var i = 0; i <= CurrentOrder.Coupons.Count - 1; i++)
            {
                CouponField.Text += CurrentOrder.Coupons[i].CouponCode.Trim().ToUpper() + "<br />";
            }

            // Notes
            var publicNotes  = new Collection <OrderNote>();
            var privateNotes = new Collection <OrderNote>();

            foreach (var note in CurrentOrder.Notes)
            {
                if (note.IsPublic)
                {
                    publicNotes.Add(note);
                }
                else
                {
                    privateNotes.Add(note);
                }
            }
            PublicNotesField.DataSource = publicNotes;
            PublicNotesField.DataBind();
            PrivateNotesField.DataSource = privateNotes;
            PrivateNotesField.DataBind();

            if (!InventoryControl.CheckCurrentOrderhasInventoryProduct())
            {
                btnDelete.OnClientClick += "return hcConfirm(event, 'Delete this order forever?');";
            }

            if (CurrentOrder.PaymentStatus != OrderPaymentStatus.Paid &&
                CurrentOrder.PaymentStatus != OrderPaymentStatus.PartiallyPaid ||
                CurrentOrder.PaymentStatus == OrderPaymentStatus.Overpaid)
            {
                btnDelete.OnClientClick += "return hcConfirm(event, 'Delete this order forever?');";
            }
        }
        /// <summary>
        /// Add a preset Pizza of specified type
        /// </summary>
        /// <param name="username"></param>
        /// <param name="stores"></param>
        /// <param name="locationChoice"></param>
        /// <param name="PresetPizza"></param>
        /// <param name="CurOrd"></param>
        public static void presetPizzaSizeChoice(string username, string storeName, Pizza PresetPizza, CurrentOrder CurOrd, bool custom)
        {
            // Get price of pizza
            int sizeOfPizza = -1;

            while (sizeOfPizza != 0)
            {
                if (!int.TryParse(Console.ReadLine(), out sizeOfPizza)) // try to read int choice
                {
                    Console.WriteLine("Not an option");
                    sizeOfPizza = -1;
                    continue;
                }
                if (sizeOfPizza == 1)
                {
                    PresetPizza.pizzaSize = Pizza.PizzaSize.twelveInch;
                }
                else if (sizeOfPizza == 2)
                {
                    PresetPizza.pizzaSize = Pizza.PizzaSize.fifteenInch;
                }
                else if (sizeOfPizza == 3)
                {
                    PresetPizza.pizzaSize = Pizza.PizzaSize.twentyInch;
                }
                else
                {
                    sizeOfPizza = -1;
                    continue;
                }
                if (custom)
                {
                    // This is the crust option
                    ZZ_PrintLoggedInHeader.printStoreHeaderLoggedIn(username, storeName);
                    {
                        int crustCheck = -1;
                        while (crustCheck < 1 || crustCheck > 3)
                        {
                            Console.WriteLine(" | Pizza Crust Selection.");
                            Console.WriteLine(" |---------------------------------------------------");
                            Console.WriteLine(" | 1. thin");
                            Console.WriteLine(" | 2. deep dish");
                            Console.WriteLine(" | 3. cheese filled");
                            Console.WriteLine(" |___________________________________________________");

                            int crustChoice = IntCheck.IntChecker();
                            if (crustChoice == -1)
                            {
                                continue;
                            }

                            if (crustChoice == 1)
                            {
                                PresetPizza.chooseCrust(Pizza.Crust.thin);
                                crustCheck = 1;
                            }
                            else if (crustChoice == 2)
                            {
                                PresetPizza.chooseCrust(Pizza.Crust.deepdish);
                                crustCheck = 1;
                            }
                            else if (crustChoice == 3)
                            {
                                PresetPizza.chooseCrust(Pizza.Crust.cheesefilled);
                                crustCheck = 1;
                            }
                            else
                            {
                                Console.WriteLine("Not an option");
                                Thread.Sleep(1100);
                            }
                        }
                    }
                    // This is the toppings choice.
                    List <string> toppings = new List <string>();
                    List <string> fullTops = new List <string>();

                    fullTops.Add("sauce");
                    fullTops.Add("cheese");
                    fullTops.Add("pepperoni");
                    fullTops.Add("sausage");
                    fullTops.Add("pineapple");

                    for (int i = 0; i < 5; i++)
                    {
                        ZZ_PrintLoggedInHeader.printStoreHeaderLoggedIn(username, storeName);
                        if (toppings.Count == 0)
                        {
                            Console.WriteLine(" | You may choose up to five toppings.. Hit enter after each submission.");
                            Console.WriteLine(" |---------------------------------------------------");
                        }
                        else
                        {
                            Console.Write(" | ");
                        }
                        foreach (var top in toppings)
                        {
                            Console.Write($" <{top}>");
                        }
                        if (toppings.Count > 0)
                        {
                            Console.WriteLine();
                        }
                        int count = 0;
                        foreach (var fTop in fullTops)
                        {
                            Console.WriteLine($" | {count+1}. {fTop}");
                            count++;
                        }

                        Console.WriteLine(" | 0. [COMPLETED TOPPING CHOICE]...");
                        Console.WriteLine(" |______________________________________________________");

                        int toppingChoice = IntCheck.IntChecker();
                        if (toppingChoice == -1 || toppingChoice > fullTops.Count)
                        {
                            i--;
                            continue;
                        }
                        if (toppingChoice == 0)
                        {
                            break;
                        }

                        // remove from remaining toppings for customer
                        string temp = fullTops[toppingChoice - 1];
                        fullTops.RemoveAt(toppingChoice - 1);
                        toppings.Add(temp);
                    }
                    foreach (var tops in toppings)
                    {
                        if (tops.Equals("sauce"))
                        {
                            PresetPizza.addToppings(Pizza.Toppings.sauce);
                        }
                        else if (tops.Equals("cheese"))
                        {
                            PresetPizza.addToppings(Pizza.Toppings.cheese);
                        }
                        else if (tops.Equals("pepperoni"))
                        {
                            PresetPizza.addToppings(Pizza.Toppings.pepperoni);
                        }
                        else if (tops.Equals("sausage"))
                        {
                            PresetPizza.addToppings(Pizza.Toppings.sausage);
                        }
                        else if (tops.Equals("pineapple"))
                        {
                            PresetPizza.addToppings(Pizza.Toppings.pineapple);
                        }
                    }
                }

                // if user chooses to confirm then add order.
                if (_g_PizzaConfirmationToOrder.PizzaConfirmToOrder(username, storeName, PresetPizza))
                {
                    double check = 0;
                    foreach (var priceCheck in CurOrd.pizzasInOrder)
                    {
                        check += priceCheck.getPriceOfPizza();
                    }
                    if ((check + PresetPizza.getPriceOfPizza()) > 250)
                    {
                        Console.WriteLine("This pizza will push your maximum order limit.\n " +
                                          "Please check out at your earliest convenience. " +
                                          "<Press any key> to return to the previous page..");
                        Console.ReadLine();
                        break;
                    }
                    // Add The pizza to the order for this restaurant and user
                    CurOrd.confirmPizzaOrder(PresetPizza, username, storeName);
                    sizeOfPizza = 0;
                }
                else
                {
                    sizeOfPizza = 0;
                }
            }
        }
Esempio n. 32
0
 public void OrderInitiate(CurrentOrder curOrd)
 {
     currentOrder = curOrd;
 }