예제 #1
0
    protected void rptCourses_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e)
    {
        MyBuyList.Shared.Entities.Menu menu = this.currentMenu;

        Meal          currentMeal      = null;
        MealDayOfWeek currentWeekDay   = null;
        int           currentWeekDayId = 0;

        int currentCourseOrMenuTypeId = ((CourseOrMealType)e.Item.DataItem).CourseOrMealTypeId;

        RepeaterItem parentItem = e.Item.Parent.Parent as RepeaterItem;

        if (parentItem != null)
        {
            currentWeekDay = parentItem.DataItem as MealDayOfWeek;
        }
        if (currentWeekDay != null)
        {
            currentWeekDayId = currentWeekDay.DayId;
        }

        if (menu.MenuTypeId == (int)MenuTypeEnum.OneMeal || menu.MenuTypeId == (int)MenuTypeEnum.QuickMenu)
        {
            foreach (Meal m in this.currentMenu.Meals.ToArray())
            {
                if (m.CourseTypeId == currentCourseOrMenuTypeId)
                {
                    currentMeal = m;
                }
            }
        }
        if (menu.MenuTypeId == (int)MenuTypeEnum.Weekly)
        {
            foreach (Meal m in this.currentMenu.Meals.ToArray())
            {
                if (m.MealTypeId == currentCourseOrMenuTypeId && m.DayIndex == currentWeekDayId)
                {
                    currentMeal = m;
                }
            }
        }

        if (currentMeal == null)
        {
            return;
        }

        this.CurrentMeal = currentMeal;

        Repeater rpt = e.Item.FindControl("rptRecipes") as Repeater;

        if (rpt != null)
        {
            rpt.DataSource = currentMeal.MealRecipes.ToArray();
            rpt.DataBind();
        }
    }
예제 #2
0
    private void BindMenuDetails(MyBuyList.Shared.Entities.Menu menu)
    {
        this.lblTitle2.Text      = menu.MenuName;
        this.lblCategories.Text  = this.GetCategoriesString(menu.MenuCategories.ToArray());
        this.lnkPublisher.Text   = menu.User.DisplayName;
        this.lblPublishDate.Text = menu.ModifiedDate.ToString("dd/MM/yyyy");
        this.lblDescription.Text = menu.Description;
        this.lblMenuTags.Text    = menu.Tags;

        if (menu.Picture != null)
        {
            this.imgMenuPicture.ImageUrl = "~/ShowPicture.ashx?MenuId=" + menu.MenuId;
        }
        else
        {
            this.imgMenuPicture.ImageUrl = "~/Images/Img_Default.jpg";
        }

        bool isInMyFavorites = (menu.UserFavoriteMenus.SingleOrDefault(ufm => ufm.UserId == ((BasePage)this.Page).UserId) != null);

        if (isInMyFavorites)
        {
            this.myFavoritesTopTag.Visible = true;
        }
        else
        {
            this.myFavoritesTopTag.Visible = false;
        }

        this.lblAllFavorites.Text = menu.UserFavoriteMenus.Count.ToString();

        if (menu.MenuTypeId == (int)MenuTypeEnum.OneMeal || menu.MenuTypeId == (int)MenuTypeEnum.QuickMenu)
        {
            this.MenuDinersNum.Visible = true;

            if (menu.Meals.Count > 0 && menu.Meals.ToArray()[0].Diners != null)
            {
                this.lblNoDiner.Text = menu.Meals.ToArray()[0].Diners.ToString();
            }

            MealDayOfWeek[] fakeDaysOfWeek = new MealDayOfWeek[1] {
                new MealDayOfWeek(1, MyGlobalResources.Sunday)
            };
            this.rptDays.DataSource = fakeDaysOfWeek;
            this.rptDays.DataBind();
        }

        if (menu.MenuTypeId == (int)MenuTypeEnum.Weekly)
        {
            this.rptDays.DataSource = this.MealDayOfWeek;
            this.rptDays.DataBind();
        }
    }
예제 #3
0
    protected void rptDays_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        MyBuyList.Shared.Entities.Menu menu = this.currentMenu;

        if (menu.MenuTypeId == (int)MenuTypeEnum.OneMeal || menu.MenuTypeId == (int)MenuTypeEnum.QuickMenu)
        {
            System.Web.UI.WebControls.Image tableTopImag = e.Item.FindControl("imgTableTop") as System.Web.UI.WebControls.Image;
            tableTopImag.ImageUrl = "~/Images/bgr_TableMenu_toPrint.jpg";

            Repeater rptCourses = e.Item.FindControl("rptCourses") as Repeater;


            var list = from item in BusinessFacade.Instance.GetCourseTypes()
                       select new CourseOrMealType(item.CourseTypeId, item.CourseTypeName);
            CourseOrMealType[] courseTypesArray = list.ToArray();

            if (menu.MenuTypeId == (int)MenuTypeEnum.OneMeal)
            {
                CourseOrMealType tempCourseType = courseTypesArray[0];
                for (int i = 0; i < (courseTypesArray.Length - 1); i++)
                {
                    courseTypesArray[i] = courseTypesArray[i + 1];
                }
                courseTypesArray[courseTypesArray.Length - 1] = tempCourseType;
                rptCourses.DataSource = courseTypesArray;
            }
            else
            {
                rptCourses.DataSource = courseTypesArray.Where(cmt => cmt.CourseOrMealTypeId == 0);
            }

            rptCourses.DataBind();
        }
        if (menu.MenuTypeId == (int)MenuTypeEnum.Weekly)
        {
            MealDayOfWeek mdow = e.Item.DataItem as MealDayOfWeek;
            if (mdow != null)
            {
                System.Web.UI.WebControls.Image tableTopImag = e.Item.FindControl("imgTableTop") as System.Web.UI.WebControls.Image;
                tableTopImag.ImageUrl = "~/Images/bgr_Table" + mdow.DayId + "_toPrint.jpg";
            }

            Repeater rptCourses = e.Item.FindControl("rptCourses") as Repeater;

            var list = from item in BusinessFacade.Instance.GetMealTypes()
                       select new CourseOrMealType(item.MealTypeId, item.MealTypeName);

            CourseOrMealType[] mealTypesArray = list.ToArray();
            rptCourses.DataSource = mealTypesArray;
            rptCourses.DataBind();
        }
    }
예제 #4
0
    protected void RebindMealsDetails()
    {
        MyBuyList.Shared.Entities.Menu menu = CurrentMenu;

        if (menu.MenuTypeId == (int)MenuTypeEnum.OneMeal || menu.MenuTypeId == (int)MenuTypeEnum.QuickMenu)
        {
            MealDayOfWeek[] fakeDaysOfWeek = new MealDayOfWeek[1] {
                new MealDayOfWeek(1, MyGlobalResources.Sunday)
            };
            rptDays.DataSource = fakeDaysOfWeek;
            rptDays.DataBind();
        }

        if (menu.MenuTypeId == (int)MenuTypeEnum.Weekly)
        {
            rptDays.DataSource = MealDayOfWeek;
            rptDays.DataBind();
        }
    }
예제 #5
0
    protected void rptCourses_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e)
    {
        Menu menu = this.currentMenu;

        Meal          currentMeal      = null;
        MealDayOfWeek currentWeekDay   = null;
        int           currentWeekDayId = 0;

        int currentCourseOrMenuTypeId = ((CourseOrMealType)e.Item.DataItem).CourseOrMealTypeId;

        RepeaterItem parentItem = e.Item.Parent.Parent as RepeaterItem;

        if (parentItem != null)
        {
            currentWeekDay = parentItem.DataItem as MealDayOfWeek;
        }
        if (currentWeekDay != null)
        {
            currentWeekDayId = currentWeekDay.DayId;
        }

        if (menu.MenuTypeId == (int)MenuTypeEnum.OneMeal || menu.MenuTypeId == (int)MenuTypeEnum.QuickMenu)
        {
            foreach (Meal m in this.currentMenu.Meals.ToArray())
            {
                if (m.CourseTypeId == currentCourseOrMenuTypeId)
                {
                    currentMeal = m;
                }

                if (currentCourseOrMenuTypeId == 6)
                {
                    Label txtComments = e.Item.FindControl("LabelComments") as Label;
                    if (txtComments != null)
                    {
                        if (m.Comments != null)
                        {
                            txtComments.Text = m.Comments.Replace("\r\n", "<br />");
                        }
                        txtComments.Visible = true;
                    }
                }
            }
        }
        if (menu.MenuTypeId == (int)MenuTypeEnum.Weekly)
        {
            foreach (Meal m in this.currentMenu.Meals.ToArray())
            {
                if (m.MealTypeId == currentCourseOrMenuTypeId && m.DayIndex == currentWeekDayId)
                {
                    currentMeal = m;
                }

                if (currentCourseOrMenuTypeId == 5 && m.DayIndex == currentWeekDayId)
                {
                    Label txtComments = e.Item.FindControl("LabelComments") as Label;
                    if (m.Comments != null)
                    {
                        txtComments.Text = m.Comments.Replace("\r\n", "<br />");
                    }
                    txtComments.Visible = true;
                }
            }
        }

        if (currentMeal == null)
        {
            return;
        }

        CurrentMeal = currentMeal;

        Repeater rpt = e.Item.FindControl("rptRecipes") as Repeater;

        if (rpt != null)
        {
            rpt.DataSource = currentMeal.MealRecipes.ToArray();
            rpt.DataBind();
        }
    }
예제 #6
0
    private void BindMenuData()
    {
        Menu menu = currentMenu;

        if (menu != null)
        {
            lblMenuName.Text    = menu.MenuName;
            lblCategories.Text  = this.GetCategoriesString(menu.MenuCategories.ToArray());
            lnkPublisher.Text   = menu.User.DisplayName;
            lblPublishDate.Text = menu.ModifiedDate.ToString("dd/MM/yyyy");
            lblDescription.Text = menu.Description;
            lblMenuTags.Text    = menu.Tags;

            //TODO: add code to change title-image "שם התפריט" to "רשימת קניות מהירה" and change lblMenuName to the date only "מתאריך ..." when the menu
            //is a quick menu.

            if (menu.Picture != null)
            {
                this.imgMenuPicture.ImageUrl = "~/ShowPicture.ashx?MenuId=" + menu.MenuId;
            }
            else if (!string.IsNullOrEmpty(menu.EmbeddedVideo) && menu.EmbeddedVideo.Contains("object") && menu.EmbeddedVideo.Contains("embed"))
            {
                this.imgMenuPicture.Visible         = false;
                this.menu_video.Style["margin-top"] = "10px";
            }
            else
            {
                this.imgMenuPicture.ImageUrl = "~/Images/Img_Default.jpg";   //needs to be changed. ask Dalit.
            }

            if (!string.IsNullOrEmpty(menu.EmbeddedVideo) && menu.EmbeddedVideo.Contains("object") && menu.EmbeddedVideo.Contains("embed"))
            {
                //adjustment method may not work for embedded videos that are not from youtube.
                this.menu_video.InnerHtml = this.AdjustVideo(menu.EmbeddedVideo);
            }
            else
            {
                this.menu_video.Visible = false;
            }

            bool isInMyFavorites = (this.currentMenu.UserFavoriteMenus.SingleOrDefault(ufm => ufm.UserId == ((BasePage)this.Page).UserId) != null);

            if (isInMyFavorites)
            {
                this.myFavoritesTopTag.Visible = true;
            }
            else
            {
                this.myFavoritesTopTag.Visible = false;
            }

            this.lblAllFavorites.Text = menu.UserFavoriteMenus.Count.ToString();

            bool isInUserFavorites = (this.currentMenu.UserFavoriteMenus.SingleOrDefault(ufm => ufm.UserId == ((BasePage)this.Page).UserId) != null);
            if (isInUserFavorites)
            {
                this.btnAddMenuToFavorites.Visible        = false;
                this.btnAddMenuToFavorites_bottom.Visible = false;
            }
            else
            {
                this.btnRemoveMenuFromFavorites.Visible        = false;
                this.btnRemoveMenuFromFavorites_bottom.Visible = false;
            }

            hlShowShoppingList.NavigateUrl        = string.Format("~/ShoppingList.aspx?menuId={0}", menu.MenuId);
            hlShowShoppingList_bottom.NavigateUrl = string.Format("~/ShoppingList.aspx?menuId={0}", menu.MenuId);
            hlPrintMenu.NavigateUrl        = string.Format("~/PrintMenu.aspx?menuId={0}", menu.MenuId);
            hlPrintMenu_bottom.NavigateUrl = string.Format("~/PrintMenu.aspx?menuId={0}", menu.MenuId);

            if (((BasePage)Page).UserId == -1)
            {
                //this.btnSendMail.Visible = false;
                //this.lblPrintMenuSeperator.Visible = false;
                //this.btnSendMail_bottom.Visible = false;
                //this.lblPrintMenuSeperator_bottom.Visible = false;
                btnAddMenuToFavorites.Visible             = false;
                btnAddMenuToFavorites_bottom.Visible      = false;
                lblAddToFavoritesSeparator.Visible        = false;
                lblAddToFavoritesSeparator_bottom.Visible = false;
            }
            if (((BasePage)Page).UserId != menu.User.UserId && (((BasePage)Page).UserType != 1))
            {
                hlEditMenu.Visible                  = false;
                btnDeleteMenu.Visible               = false;
                lblSendMailSeparator.Visible        = false;
                lblEditMenuSeperator.Visible        = false;
                hlEditMenu_bottom.Visible           = false;
                btnDeleteMenu_bottom.Visible        = false;
                lblSendMailSeparator_bottom.Visible = false;
                lblEditMenuSeperator_bottom.Visible = false;
            }

            if (menu.MenuTypeId == (int)MenuTypeEnum.QuickMenu)
            {
                hlEditMenu.Visible                  = false;
                hlEditMenu_bottom.Visible           = false;
                lblSendMailSeparator.Visible        = false;
                lblSendMailSeparator_bottom.Visible = false;
            }

            if (menu.MenuTypeId == (int)MenuTypeEnum.OneMeal || menu.MenuTypeId == (int)MenuTypeEnum.QuickMenu)
            {
                MenuDinersNum.Visible = true;

                if (menu.Meals.Count > 0 && menu.Meals.ToArray()[0].Diners != null)
                {
                    this.lblNoDiner.Text = menu.Meals.ToArray()[0].Diners.ToString();
                }
                MealDayOfWeek[] fakeDaysOfWeek = new MealDayOfWeek[1] {
                    new MealDayOfWeek(1, MyGlobalResources.Sunday)
                };
                rptDays.DataSource = fakeDaysOfWeek;
                rptDays.DataBind();
            }

            if (menu.MenuTypeId == (int)MenuTypeEnum.Weekly)
            {
                this.rptDays.DataSource = this.MealDayOfWeek;
                this.rptDays.DataBind();
            }

            string userEmail   = string.Empty;
            User   currentUser = BusinessFacade.Instance.GetUser(((BasePage)this.Page).UserId);
            if (currentUser != null)
            {
                userEmail = currentUser.Email;
            }
            ucSendMailToFriend.BindItemDetails("Menu", menu.MenuId, menu.MenuName, userEmail);
        }
    }
예제 #7
0
    protected void rptCourses_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e)
    {
        MyBuyList.Shared.Entities.Menu menu = this.CurrentMenu;

        Meal          currentMeal          = null;
        MealDayOfWeek currentWeekDay       = null;
        int           currentWeekDayId     = 0;
        string        currentMealSignature = "";

        int currentCourseOrMenuTypeId = ((CourseOrMealType)e.Item.DataItem).CourseOrMealTypeId;

        RepeaterItem parentItem = e.Item.Parent.Parent as RepeaterItem;

        if (parentItem != null)
        {
            currentWeekDay = parentItem.DataItem as MealDayOfWeek;
        }
        if (currentWeekDay != null)
        {
            currentWeekDayId = currentWeekDay.DayId;
        }

        TextBox txtComments = null;

        if (menu.MenuTypeId == (int)MenuTypeEnum.OneMeal && currentCourseOrMenuTypeId == 6)
        {
            txtComments                     = e.Item.FindControl("TextBoxComments") as TextBox;
            txtComments.Visible             = true;
            txtComments.Attributes["DayId"] = currentWeekDayId.ToString();
            if (_comments != null && _comments.Count != 0)
            {
                txtComments.Text = _comments[currentWeekDayId - 1];
            }
        }

        if (menu.MenuTypeId == (int)MenuTypeEnum.Weekly && currentCourseOrMenuTypeId == 5)
        {
            txtComments                     = e.Item.FindControl("TextBoxComments") as TextBox;
            txtComments.Visible             = true;
            txtComments.Attributes["DayId"] = currentWeekDayId.ToString();
            if (_comments != null && _comments.Count != 0)
            {
                txtComments.Text = _comments[currentWeekDayId - 1];
            }
        }

        if (menu.MenuTypeId == (int)MenuTypeEnum.OneMeal)
        {
            foreach (Meal m in this.CurrentMenu.Meals.ToArray())
            {
                if (m.CourseTypeId == currentCourseOrMenuTypeId)
                {
                    currentMeal = m;
                }

                if (currentCourseOrMenuTypeId == 6 && !string.IsNullOrEmpty(m.Comments))
                {
                    if (string.IsNullOrEmpty(txtComments.Text))
                    {
                        txtComments.Text = m.Comments;
                        _comments[currentWeekDayId - 1] = m.Comments;
                    }
                }
            }

            currentMealSignature = "d0m4c" + currentCourseOrMenuTypeId;
        }
        if (menu.MenuTypeId == (int)MenuTypeEnum.Weekly)
        {
            foreach (Meal m in this.CurrentMenu.Meals.ToArray())
            {
                if (m.MealTypeId == currentCourseOrMenuTypeId && m.DayIndex == currentWeekDayId)
                {
                    currentMeal = m;
                }

                if (currentCourseOrMenuTypeId == 5 && m.DayIndex == currentWeekDayId && !string.IsNullOrEmpty(m.Comments))
                {
                    if (string.IsNullOrEmpty(txtComments.Text))
                    {
                        txtComments.Text = m.Comments;
                        _comments[currentWeekDayId - 1] = m.Comments;
                    }
                }
            }

            currentMealSignature = "d" + currentWeekDayId + "m" + currentCourseOrMenuTypeId + "c0";
        }

        // for identification of relevant meal after recipe was dropped on the table cell.
        HtmlTableCell tdMealRecipes = e.Item.FindControl("tdMealRecipes") as HtmlTableCell;

        if (tdMealRecipes != null)
        {
            tdMealRecipes.Attributes["meal_signature"] = currentMealSignature;
        }

        if (currentMeal == null)
        {
            tdMealRecipes.Controls.Add(new LiteralControl("&nbsp;")); //for IE
            return;
        }
        if (currentMeal.MealRecipes.Count == 0)
        {
            tdMealRecipes.Controls.Add(new LiteralControl("&nbsp;")); //for IE
        }

        if (this.CurrentMenu.MenuTypeId == (int)MenuTypeEnum.OneMeal && txtComments != null)
        {
            txtComments.Text = currentMeal.Comments;
        }

        if (this.CurrentMenu.MenuTypeId == (int)MenuTypeEnum.Weekly)
        {
            HtmlTableCell tdDinersNum = e.Item.FindControl("tdDinersNum") as HtmlTableCell;
            if (tdDinersNum != null)
            {
                tdDinersNum.Style["width"]          = "33px";
                tdDinersNum.Style["padding-right"]  = "2px";
                tdDinersNum.Style["padding-top"]    = "5px";
                tdDinersNum.Style["padding-bottom"] = "5px";
            }

            TextBox txtDinersNum = e.Item.FindControl("txtDinersNum") as TextBox;
            if (txtDinersNum != null)
            {
                txtDinersNum.Attributes["mealSignature"] = this.GetMealSignature(currentMeal);
                txtDinersNum.Text    = currentMeal.Diners.ToString();
                txtDinersNum.Visible = true;
            }
        }

        Repeater rpt = e.Item.FindControl("rptRecipes") as Repeater;

        if (rpt != null)
        {
            rpt.DataSource = currentMeal.MealRecipes.ToArray();
            rpt.DataBind();
        }
    }