Exemplo n.º 1
0
        public static List<ngOrderEntry> AddContainersToFood(ngUserModel user, int day, List<ngOrderEntry> orders)
        {
            List<ngOrderEntry> filteredOrders = RemoveContainers(orders, day);

            int smallContainersCount = 0;
            int bigContainersCount = 0;

            int meathOrFish = 0;
            int garnirOrSalat = 0;
            foreach (ngOrderEntry order in orders) {
                if (order.Count > 0) {
                    ngFoodItem food = FoodManager.Inst.GetFoodById(day, order.FoodId);
                    Debug.Assert(null != food);

                    if (food.isFirst) {
                        smallContainersCount++;
                        if (food.isKvasolevaOrChanachi) {
                            smallContainersCount++;
                        }
                    }
                    else if (food.isMeatOrFish) {
                        meathOrFish++;
                    }
                    else if (food.isSalat || food.isGarnir) {
                        garnirOrSalat++;
                    }
                }
            }

            if ((garnirOrSalat == 1 && meathOrFish == 0) || (garnirOrSalat == 0 && meathOrFish == 1)) {
                smallContainersCount++;
            }
            else if ((garnirOrSalat != 0) || (meathOrFish != 0)) {
                bigContainersCount = Convert.ToInt16(Math.Round(garnirOrSalat/(decimal) 2, MidpointRounding.ToEven));
                if (garnirOrSalat%2 > 0) {
                    smallContainersCount++;
                }
            }

            List<ngOrderEntry> res = new List<ngOrderEntry>();
            res.AddRange(filteredOrders);

            //update small containers cout
            ngFoodItem foodSmallContainer = FoodManager.Inst.GetSmallContainer(day);
            Debug.Assert(null != foodSmallContainer);
            ngOrderEntry smallContainerOrder = new ngOrderEntry();
            smallContainerOrder.FoodId = foodSmallContainer.FoodId;
            smallContainerOrder.Count = smallContainersCount;
            res.Add(smallContainerOrder);

            //update big containers count
            ngFoodItem foodBigContainer = FoodManager.Inst.GetBigContainer(day);
            Debug.Assert(null != foodBigContainer);
            ngOrderEntry bigContainerOrder = new ngOrderEntry();
            bigContainerOrder.FoodId = foodBigContainer.FoodId;
            bigContainerOrder.Count = bigContainersCount;
            res.Add(bigContainerOrder);

            return res;
        }
Exemplo n.º 2
0
 public string formatCount(ngOrderEntry order)
 {
     string res = order.Count.As<string>() + "";
     ngFoodItem food = getFoodItem(order.FoodId);
     if (food.IsByWeightItem) {
         res = JsContext.parseInt((order.Count*100).As<string>(), 10).As<string>() + "";
     }
     return res;
 }