コード例 #1
0
        public List <int> GetDaysWithAllergens(int cartCalendarId)
        {
            try
            {
                List <int>          daysWithAllergens = new List <int>();
                hccProgramPlan      plan    = hccProgramPlan.GetById(this.Plan_PlanID.Value);
                hccUserProfile      profile = hccUserProfile.GetById(this.UserProfileID);
                hccCartItemCalendar cartCal = hccCartItemCalendar.GetById(cartCalendarId);

                if (plan != null && profile != null)
                {
                    // get list of user profile allergens
                    List <hccAllergen> userAllergens = profile.GetAllergens();

                    if (userAllergens.Count > 0)
                    {
                        List <hccProgramDefaultMenu> defaultMenus = hccProgramDefaultMenu.GetBy(cartCal.CalendarID, plan.ProgramID);

                        defaultMenus.ForEach(delegate(hccProgramDefaultMenu defaultMenu)
                        {
                            hccCartDefaultMenuException excMenu = hccCartDefaultMenuException.GetBy(defaultMenu.DefaultMenuID, cartCal.CartCalendarID);
                            List <hccAllergen> menuAllg         = new List <hccAllergen>();

                            if (excMenu == null)
                            {
                                hccMenuItem item = hccMenuItem.GetById(defaultMenu.MenuItemID);
                                if (item != null)
                                {
                                    menuAllg = item.GetAllergens();
                                }
                            }
                            else
                            {
                                menuAllg = excMenu.GetMenuItemAllergens();
                            }

                            if (menuAllg.Count > 0)
                            {
                                if (userAllergens.Intersect(menuAllg).Count() > 0)
                                {
                                    daysWithAllergens.Add(defaultMenu.DayNumber);
                                }
                            }
                        });
                    }
                }
                return(daysWithAllergens);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #2
0
        public List <hccAllergen> GetMenuItemAllergens()
        {
            try
            {
                List <hccAllergen> algns = new List <hccAllergen>();
                hccMenuItem        item  = hccMenuItem.GetById(this.MenuItemID);

                if (item != null)
                {
                    algns.AddRange(item.GetAllergens());
                }

                return(algns);
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #3
0
        public static decimal GetItemPriceBySize(hccMenuItem menuItem, int?itemSize)
        {
            switch ((Enums.CartItemSize)itemSize)
            {
            case Enums.CartItemSize.ChildSize:
                return(menuItem.CostChild);

            case Enums.CartItemSize.SmallSize:
                return(menuItem.CostSmall);

            case Enums.CartItemSize.RegularSize:
                return(menuItem.CostRegular);

            case Enums.CartItemSize.LargeSize:
                return(menuItem.CostLarge);

            default: return(0.00m);
            }
        }
コード例 #4
0
        public MOTCartItem(hccCartItem cartItem)
        {
            try
            {
                if (cartItem.ItemType == Common.Enums.CartItemType.AlaCarte)
                {
                    hccMenuItem mi = hccMenuItem.GetById(cartItem.Meal_MenuItemID.Value);
                    MenuItem     = mi;
                    CartItem     = cartItem;
                    CartItemId   = cartItem.CartItemID;
                    OrderNumber  = cartItem.OrderNumber + "-ALC";
                    DeliveryDate = cartItem.DeliveryDate;

                    if (cartItem.UserProfile != null)
                    {
                        CustomerName = cartItem.UserProfile.ParentProfileName;
                        ProfileName  = cartItem.UserProfile.ProfileName;
                    }

                    ItemName = mi.Name;
                    MealType = mi.MealType;

                    if (cartItem.Meal_MealSizeID.HasValue)
                    {
                        Enums.CartItemSize size = (Enums.CartItemSize)cartItem.Meal_MealSizeID;

                        if (size == Enums.CartItemSize.NoSize)
                        {
                            size = Enums.CartItemSize.RegularSize;
                        }

                        PortionSize = Enums.GetEnumDescription(size);
                    }
                    else
                    {
                        PortionSize = Enums.GetEnumDescription(Enums.CartItemSize.RegularSize);
                    }

                    Servings    = cartItem.Quantity.ToString();
                    Preferences = hccCartItemMealPreference.GetPrefsBy(cartItem.CartItemID)
                                  .Select(a => a.Name).DefaultIfEmpty("None").Aggregate((c, d) => c + ", " + d);
                    Sides = "None";

                    if (hccMenuItem.EntreeMealTypes.Contains(MealType) && cartItem.MealSideMenuItems.Count > 0)
                    {
                        Sides = cartItem.GetMealSideMenuItemsAsSectionString(", ");
                    }

                    if (cartItem.SnapShipAddrId.HasValue)
                    {
                        hccAddress addr = hccAddress.GetById(cartItem.SnapShipAddrId.Value);
                        DeliveryMethod = ((Enums.DeliveryTypes)addr.DefaultShippingTypeID).ToString();
                    }
                    if (cartItem.Plan_IsAutoRenew == true)
                    {
                        FamilyStyle = "Yes";
                    }
                    else if (cartItem.Plan_IsAutoRenew == false)
                    {
                        FamilyStyle = "No";
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #5
0
        public List <Day> BindWeeklyGlance(List <hccProgramDefaultMenu> defaultMenuSelections, int numDaysPerWeek, int cartItemId)
        {
            StringBuilder      sb    = new StringBuilder();
            List <hccMenuItem> lstMI = new List <hccMenuItem>();
            Day       d  = new Day();
            MealTypes mT = new MealTypes();

            string currentMealType = "";
            int    i, currentDay = 1;

            for (i = 1; i <= numDaysPerWeek; i++)
            {
                int lastTypeId = 0;

                defaultMenuSelections.Where(a => a.DayNumber == i)
                .OrderBy(a => a.MealTypeID).ToList().ForEach(delegate(hccProgramDefaultMenu defaultSelection)
                {
                    int menuItemId     = defaultSelection.MenuItemID;
                    int menuItemSizeId = defaultSelection.MenuItemSizeID;

                    hccCartItemCalendar cartCal = hccCartItemCalendar.GetBy(cartItemId, CurrentCalendarId);

                    hccCartDefaultMenuException menuItemExc
                        = hccCartDefaultMenuException.GetBy(defaultSelection.DefaultMenuID, cartCal.CartCalendarID);

                    if (menuItemExc != null)
                    {
                        menuItemId     = menuItemExc.MenuItemID;
                        menuItemSizeId = menuItemExc.MenuItemSizeID;

                        List <hccCartDefaultMenuExPref> prefs = hccCartDefaultMenuExPref.GetBy(menuItemExc.DefaultMenuExceptID);
                    }
                    if (menuItemId > 0)
                    {
                        hccMenuItem menuItem = hccMenuItem.GetById(menuItemId);

                        //if (defaultSelection.MealTypeID != lastTypeId)
                        //{
                        lastTypeId = defaultSelection.MealTypeID;

                        if (((Enums.MealTypes)lastTypeId).ToString().ToLower().Contains("breakfast"))
                        {
                            currentMealType = "breakfast";
                        }
                        else if (((Enums.MealTypes)lastTypeId).ToString().ToLower().Contains("lunch"))
                        {
                            currentMealType = "lunch";
                        }
                        else if (((Enums.MealTypes)lastTypeId).ToString().ToLower().Contains("dinner"))
                        {
                            currentMealType = "dinner";
                        }
                        else if (((Enums.MealTypes)lastTypeId).ToString().ToLower().Contains("dessert"))
                        {
                            currentMealType = "dessert";
                        }
                        else if (((Enums.MealTypes)lastTypeId).ToString().ToLower().Contains("snack"))
                        {
                            currentMealType = "snack";
                        }

                        if (mT.MealType != currentMealType && mT.MealType != null)
                        {
                            if (sb.ToString().EndsWith(",<br />") == true)
                            {
                                mT.MealInfo = sb.ToString().Substring(0, sb.ToString().Length - 7);
                            }
                            //mT.MealInfo = sb.ToString().Trim().TrimEnd(',');

                            d.MealTypes.Add(mT);

                            mT = new MealTypes();
                            sb = new StringBuilder();
                        }

                        mT.MealType = currentMealType;

                        if (menuItem != null)
                        {
                            sb.Append(menuItem.Name);
                            sb.Append(",<br />");
                        }

                        /*if (((Enums.CartItemSize)menuItemSizeId) != Enums.CartItemSize.NoSize)
                         * {
                         *  sb.Append(" - " + Enums.GetEnumDescription(((Enums.CartItemSize)menuItemSizeId)));
                         *  sb.Append(", ");
                         * } */
                        if (currentDay != defaultSelection.DayNumber)         // only create a new day when daynumber changes
                        {
                            sb.ToString().Trim().TrimEnd(',');
                            d.DayTitle = currentDay.ToString();
                            //d.DayTitle = "Day: " + currentDay.ToString();
                            d.DayNumber = currentDay;
                            days.Add(d);
                            d          = new Day();
                            currentDay = defaultSelection.DayNumber;
                        }
                        //}
                        menuItemId = 0;
                    }
                });
            }
            if (sb.ToString().EndsWith(",<br />") == true)
            {
                mT.MealInfo = sb.ToString().Substring(0, sb.ToString().Length - 7);
            }
            //mT.MealInfo = sb.ToString().Trim().TrimEnd(',');
            d.MealTypes.Add(mT);
            d.DayTitle = currentDay.ToString();
            //d.DayTitle = "Day: " + currentDay.ToString();
            d.DayNumber = currentDay;
            days.Add(d);

            return(days);
        }