Exemplo n.º 1
0
        public static bool AddRecipeToList(int recipeId, int servings)
        {
            SRL_User user = (SRL_User)HttpContext.Current.Session[AppConstants.SITE_USER];

            if (user == null)
            {
                return(false);
            }

            Recipe recipe = BusinessFacade.Instance.GetRecipe(recipeId);
            List <SRL_Ingredient> ingredients =
                (from p in recipe.Ingredients
                 select
                 new SRL_Ingredient
            {
                //Id = p.IngredientId,
                FoodName = p.FoodName,
                CompleteValue = p.Quantity.ToString(),
                MeasurementUnitId = p.MeasurementUnitId,
                MeasurementUnitName = p.MeasurementUnit.ToString()
            }).ToList();

            int newListId = BusinessFacade.Instance.AddGeneralList(user.UserId, ListTypes.ShoppingList);

            foreach (SRL_Ingredient ingredient in ingredients)
            {
                bool addGeneralListItem = BusinessFacade.Instance.AddGeneralListItem(ingredient, newListId);
            }

            return(true);
        }
Exemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        user = (SRL_User)Session[AppConstants.SITE_USER];

        if (!IsPostBack)
        {
            LoadRoutineLists();
        }
    }
Exemplo n.º 3
0
        public void RefreshList()
        {
            SRL_User user = (SRL_User)Session[AppConstants.SITE_USER];

            if (user == null)
            {
                return;
            }

            //int listId = BusinessFacade.Instance.GetSummeryList(user.UserId);
            //List<SRL_Ingredient> summeryListDetails = BusinessFacade.Instance.GetSummeryListDetails(listId);
            //Ingredients = summeryListDetails;
        }
Exemplo n.º 4
0
    protected void SaveRoutineList(object sender, ImageClickEventArgs e)
    {
        user = (SRL_User)Session[AppConstants.SITE_USER];

        int summeryId = BusinessFacade.Instance.GetSummeryList(user.UserId);
        List <SRL_Ingredient> summeryList = BusinessFacade.Instance.GetSummeryListDetails(summeryId);

        List <SRL_Ingredient> currentIngredients = ucIngridians1.Ingredients;

        int listId = 0;

        //if (rbNewList.Checked)
        //    listId = BusinessFacade.Instance.AddRoutineList(user.UserId, txtName.Text);

        if (rbFromList.Checked)
        {
            int.TryParse(ddlNames.SelectedValue, out listId);
        }

        if (listId == 0)
        {
            return;
        }

        //List<SRL_Ingredient> routineList = BusinessFacade.Instance.GetRoutineListDetails(listId);
        //if (routineList != null)
        //    foreach (SRL_Ingredient ingredient in routineList)
        //    {
        //        int foodId = ingredient.FoodId;
        //        SRL_Ingredient find = currentIngredients.Find(f => f.FoodId == foodId);
        //        if (find == null)
        //        {
        //            BusinessFacade.Instance.DeleteRoutineListItem(ingredient.IngredientId);

        //            SRL_Ingredient summeryIngrediant = summeryList.Find(f => f.FoodId == foodId);
        //            BusinessFacade.Instance.DeleteSummeryListItem(summeryId, listId, summeryIngrediant);
        //        }
        //    }

        int summeryListId = BusinessFacade.Instance.AddSummeryList(user.UserId);

        foreach (SRL_Ingredient ingredient in currentIngredients)
        {
            //bool result = BusinessFacade.Instance.AddRoutineListItem(ingredient, listId);
            bool addSummeryListItem = BusinessFacade.Instance.AddSummeryListItem(ingredient, summeryListId, listId);
        }

        txtName.Text = string.Empty;

        ucSummeryList1.RefreshList();
    }
Exemplo n.º 5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        SRL_User user = (SRL_User)Session[AppConstants.SITE_USER];

        if (user == null)
        {
            return;
        }

        if (!IsPostBack)
        {
            int listId;
            //List<SRL_Ingredient> shortageList = BusinessFacade.Instance.GetShortageList(user.UserId, out listId);
            //ucIngridians1.Ingredients = shortageList;
            ucIngridians1.AddItem += AfterAddItem;
        }
    }
Exemplo n.º 6
0
    protected void SaveShortageList(object sender, ImageClickEventArgs e)
    {
        SRL_User user = (SRL_User)Session[AppConstants.SITE_USER];

        if (user == null)
        {
            return;
        }

        List <SRL_Ingredient> currentIngredientList = ucIngridians1.Ingredients;
        int listId;
        //List<SRL_Ingredient> savedIngrediantList = BusinessFacade.Instance.GetShortageList(user.UserId, out listId);

        int summeryId = BusinessFacade.Instance.GetSummeryList(user.UserId);
        List <SRL_Ingredient> summeryList = BusinessFacade.Instance.GetSummeryListDetails(summeryId);

        //if (savedIngrediantList != null)
        //{
        //    foreach (SRL_Ingredient ingredient in savedIngrediantList)
        //    {
        //        string foodName = ingredient.FoodName;
        //        SRL_Ingredient find = currentIngredientList.ToList().Find(f => f.FoodName == foodName);
        //        if (find == null)
        //        {
        //            BusinessFacade.Instance.DeleteShortageListItem(ingredient.IngredientId);

        //            SRL_Ingredient ingredient1 = ingredient;
        //            SRL_Ingredient summeryIngrediant = summeryList.Find(f => f.FoodId == ingredient1.FoodId);
        //            BusinessFacade.Instance.DeleteSummeryListItem(summeryId, listId, summeryIngrediant);
        //        }
        //    }
        //}

        //listId = BusinessFacade.Instance.AddShortageList(user.UserId);
        int summeryListId = BusinessFacade.Instance.AddSummeryList(user.UserId);

        foreach (SRL_Ingredient ingredient in currentIngredientList)
        {
            //bool result = BusinessFacade.Instance.AddShortageListItem(ingredient, listId);
            //bool addSummeryListItem = BusinessFacade.Instance.AddSummeryListItem(ingredient, summeryListId, listId);
        }

        ucSummeryList1.RefreshList();
    }
Exemplo n.º 7
0
    public static bool AddRecipeToList(int recipeId, int servings)
    {
        SRL_User user = (SRL_User)HttpContext.Current.Session[AppConstants.SITE_USER];

        if (user == null)
        {
            return(false);
        }

        Recipe recipe = BusinessFacade.Instance.GetRecipe(recipeId);

        int rem;
        int multiplyServiceFactor = Math.DivRem(servings, recipe.Servings, out rem);

        if (rem != 0)
        {
            multiplyServiceFactor += 1;
        }

        List <SRL_Ingredient> ingredients =
            (from p in recipe.Ingredients
             select
             new SRL_Ingredient
        {
            //IngredientId = p.IngredientId,
            FoodId = p.FoodId,
            FoodName = p.Food.FoodName,
            Quantity = (p.Quantity * multiplyServiceFactor),
            MeasurementUnitId = p.MeasurementUnitId,
            MeasurementUnitName = p.MeasurementUnit.UnitName
        }).ToList();

        int summeryListId = BusinessFacade.Instance.AddSummeryList(user.UserId);

        foreach (SRL_Ingredient ingredient in ingredients)
        {
            bool addSummeryListItem = BusinessFacade.Instance.AddSummeryListItem(ingredient, summeryListId, recipeId);
        }

        return(true);
    }