コード例 #1
0
ファイル: ApiUtils.cs プロジェクト: mgerasika/gam-gam
        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;
        }
コード例 #2
0
ファイル: ApiUtils.cs プロジェクト: mgerasika/gam-gam
 public static void SendEmail(ngUserModel user, string subject,string msg)
 {
     SmtpClient client = new SmtpClient("smtp.gmail.com", 587) { Credentials = new NetworkCredential("*****@*****.**", "nikita1984"), EnableSsl = true };
     client.Send("*****@*****.**", "*****@*****.**", subject, msg);
     client.Send("*****@*****.**", user.Email, subject, msg);
 }