Пример #1
0
        public ActionResult RemoveShoppingItem(int ingredientId)
        {
            var data = new object();

            try
            {
                using (var db = new DIYFE.EF.DIYFEEntities())
                {
                    IngredientShopping deltedItem = db.IngredientShoppings.Where(i => i.IngredientId == ingredientId).FirstOrDefault();
                    if (deltedItem != null)
                    {
                        db.Entry(deltedItem).State = System.Data.EntityState.Deleted;
                        db.SaveChanges();
                    }
                    ;
                }

                data = new { success = true };
            }
            catch (Exception ex)
            {
                if (ex.InnerException.Message != null)
                {
                    data = new { success = false, message = ex.InnerException.Message };
                }
                else
                {
                    data = new { success = false, message = ex.Message + " Another reason why EF sucks" };
                }
                return(Json(data));
            }

            return(Json(data));
        }
Пример #2
0
        public ActionResult DailyRecipeRemove(int recipeDayId)
        {
            var data = new object();

            try
            {
                using (var db = new DIYFE.EF.DIYFEEntities())
                {
                    RecipeDay deltedRecipe = db.RecipeDays.Where(rd => rd.RecipeDayId == recipeDayId).FirstOrDefault();
                    if (deltedRecipe != null)
                    {
                        db.Entry(deltedRecipe).State = System.Data.EntityState.Deleted;
                        db.SaveChanges();
                    }
                    ;
                }

                data = new { success = true };
            }
            catch (Exception ex)
            {
                if (ex.InnerException.Message != null)
                {
                    data = new { success = false, message = ex.InnerException.Message };
                }
                else
                {
                    data = new { success = false, message = ex.Message + " Another reason why EF sucks" };
                }
                return(Json(data));
            }

            return(Json(data));
        }
Пример #3
0
        public ActionResult AddShoppingItem(int ingredientId)
        {
            var data = new object();

            IngredientShopping rd = new IngredientShopping
            {
                IngredientId = ingredientId
            };

            try
            {
                using (var db = new DIYFE.EF.DIYFEEntities())
                {
                    db.Entry(rd).State = System.Data.EntityState.Added;
                    db.SaveChanges();
                }

                data = new { success = true };
            }
            catch (Exception ex)
            {
                if (ex.InnerException.Message != null)
                {
                    data = new { success = false, message = ex.InnerException.Message };
                }
                else
                {
                    data = new { success = false, message = ex.Message + " Another reason why EF sucks" };
                }
                return(Json(data));
            }

            return(Json(data));
        }
Пример #4
0
        public ActionResult ArticleDetails(string articleType, string categoryUrl, string subCategoryUrl, string subSubCategoryUrl, string articleName)
        {
            int categoryRowId = 0;

            ArticleModel model = new ArticleModel();
            Category     cat   = new Category();

            using (var db = new DIYFE.EF.DIYFEEntities())
            {
                model.Article = db.Articles.Include("ArticleComments").Where(a => a.URLLink == articleName + ".html").FirstOrDefault();
                model.Article.ViewRequests++;
                db.Entry(model.Article).State = System.Data.EntityState.Modified;
                db.SaveChanges();
            }

            if (model.Article != null)
            {
                cat = StaticConfig.GetCatigroy(model.Article.CategoryRowId);

                model.CrumbLinkList   = StaticConfig.GenerateCrumbLinks(cat, articleType);
                model.RelatedTreeView = StaticConfig.GenerateRelatedTreeView(cat, articleType);

                PageModel.Title       = model.Article.Title;
                PageModel.Description = model.Article.Description;
                PageModel.Author      = model.Article.Author;
                PageModel.Keywords    = model.Article.Keywords;
            }
            else
            {
                //JUST TO GET BY -- REPLACE WITH 404 SOULATION
                model.CrumbLinkList = StaticConfig.GenerateCrumbLinks(new Category(), articleType);
                model.Article       = new Article();
                model.Comments      = new List <ArticleComment>();
                //model.RelatedTreeView = DIYFEHelper.GenerateTreeViewThirdLev(model.Article.CategoryRowId, linkPrefix);

                PageModel.Title       = "";
                PageModel.Description = "";
                PageModel.Author      = "";
                PageModel.Keywords    = "";
            }


            // model.Comments = la.ArticleComments(model.Article.ArticleId);

            //model.MostViewed = la.MostViewed(11, 20);
            // model.CrumbLinkList = DIYFEHelper.GenerateCrumbLinks(categoryRowId, linkPrefix);
            model.RelatedTreeView = StaticConfig.GenerateTreeViewThirdLev(cat, articleType);

            ////PageModel.Title = model.Article.Title;
            ////PageModel.Description = model.Article.Description;
            ////PageModel.Author = model.Article.Author;
            ////PageModel.Keywords = model.Article.Keywords;

            return(View(model));
        }
Пример #5
0
        public ActionResult ArticleDetails(string articleType, string categoryUrl, string subCategoryUrl, string subSubCategoryUrl, string articleName)
        {
            int categoryRowId = 0;

            ArticleModel model = new ArticleModel();
            Category cat = new Category();

            using (var db = new DIYFE.EF.DIYFEEntities())
            {
                model.Article = db.Articles.Include("ArticleComments").Where(a => a.URLLink == articleName + ".html").FirstOrDefault();
                model.Article.ViewRequests++;
                db.Entry(model.Article).State = System.Data.EntityState.Modified;
                db.SaveChanges();
            }

            if (model.Article != null)
            {
                cat = StaticConfig.GetCatigroy(model.Article.CategoryRowId);

                model.CrumbLinkList = StaticConfig.GenerateCrumbLinks(cat, articleType);
                model.RelatedTreeView = StaticConfig.GenerateRelatedTreeView(cat, articleType);

                PageModel.Title = model.Article.Title;
                PageModel.Description = model.Article.Description;
                PageModel.Author = model.Article.Author;
                PageModel.Keywords = model.Article.Keywords;
            }
            else
            {
                //JUST TO GET BY -- REPLACE WITH 404 SOULATION
                model.CrumbLinkList = StaticConfig.GenerateCrumbLinks(new Category(), articleType);
                model.Article = new Article();
                model.Comments = new List<ArticleComment>();
                //model.RelatedTreeView = DIYFEHelper.GenerateTreeViewThirdLev(model.Article.CategoryRowId, linkPrefix);

                PageModel.Title = "";
                PageModel.Description = "";
                PageModel.Author = "";
                PageModel.Keywords = "";
            }

            // model.Comments = la.ArticleComments(model.Article.ArticleId);

            //model.MostViewed = la.MostViewed(11, 20);
            // model.CrumbLinkList = DIYFEHelper.GenerateCrumbLinks(categoryRowId, linkPrefix);
            model.RelatedTreeView = StaticConfig.GenerateTreeViewThirdLev(cat, articleType);

            ////PageModel.Title = model.Article.Title;
            ////PageModel.Description = model.Article.Description;
            ////PageModel.Author = model.Article.Author;
            ////PageModel.Keywords = model.Article.Keywords;

            return View(model);
        }
Пример #6
0
        public ActionResult AddToDay(int dayId, int recipeId)
        {
            var data = new object();

            RecipeDay rd = new RecipeDay
            {
                DayId    = dayId,
                RecipeId = recipeId,
                Active   = true
            };

            try
            {
                using (var db = new DIYFE.EF.DIYFEEntities())
                {
                    db.Entry(rd).State = System.Data.EntityState.Added;
                    db.SaveChanges();
                }

                data = new { success = true };
            }
            catch (Exception ex)
            {
                if (ex.InnerException.Message != null)
                {
                    data = new { success = false, message = ex.InnerException.Message };
                }
                else
                {
                    data = new { success = false, message = ex.Message + " Another reason why EF sucks" };
                }
                return(Json(data));
            }

            return(Json(data));
        }
Пример #7
0
        public ActionResult AddShoppingItem(int ingredientId)
        {
            var data = new object();

            IngredientShopping rd = new IngredientShopping
            {
                IngredientId = ingredientId
            };

            try
            {
                using (var db = new DIYFE.EF.DIYFEEntities())
                {

                    db.Entry(rd).State = System.Data.EntityState.Added;
                    db.SaveChanges();
                }

                data = new { success = true };
            }
            catch (Exception ex)
            {
                if (ex.InnerException.Message != null)
                {
                    data = new { success = false, message = ex.InnerException.Message };
                }
                else
                {
                    data = new { success = false, message = ex.Message + " Another reason why EF sucks" };
                }
                return Json(data);

            }

            return Json(data);
        }
Пример #8
0
        public ActionResult AddToDay(int dayId, int recipeId)
        {
            var data = new object();

            RecipeDay rd = new RecipeDay
            {
                DayId = dayId,
                RecipeId = recipeId,
                Active = true
            };

            try
            {
                using (var db = new DIYFE.EF.DIYFEEntities())
                {

                    db.Entry(rd).State = System.Data.EntityState.Added;
                    db.SaveChanges();
                }

                data = new { success = true };
            }
            catch (Exception ex)
            {
                if (ex.InnerException.Message != null)
                {
                    data = new { success = false, message = ex.InnerException.Message };
                }
                else
                {
                    data = new { success = false, message = ex.Message + " Another reason why EF sucks" };
                }
                return Json(data);

            }

            return Json(data);
        }
Пример #9
0
        public ActionResult RemoveShoppingItem(int ingredientId)
        {
            var data = new object();

            try
            {
                using (var db = new DIYFE.EF.DIYFEEntities())
                {

                    IngredientShopping deltedItem = db.IngredientShoppings.Where(i => i.IngredientId == ingredientId).FirstOrDefault();
                    if (deltedItem != null)
                    {
                        db.Entry(deltedItem).State = System.Data.EntityState.Deleted;
                        db.SaveChanges();
                    };
                }

                data = new { success = true };
            }
            catch (Exception ex)
            {
                if (ex.InnerException.Message != null)
                {
                    data = new { success = false, message = ex.InnerException.Message };
                }
                else
                {
                    data = new { success = false, message = ex.Message + " Another reason why EF sucks" };
                }
                return Json(data);

            }

            return Json(data);
        }
Пример #10
0
        public ActionResult DailyRecipeRemove(int recipeDayId)
        {
            var data = new object();

            try
            {
                using (var db = new DIYFE.EF.DIYFEEntities())
                {
                    RecipeDay deltedRecipe = db.RecipeDays.Where(rd => rd.RecipeDayId == recipeDayId).FirstOrDefault();
                    if (deltedRecipe != null)
                    {
                        db.Entry(deltedRecipe).State = System.Data.EntityState.Deleted;
                        db.SaveChanges();
                    };
                }

                data = new { success = true };
            }
            catch (Exception ex)
            {
                if (ex.InnerException.Message != null)
                {
                    data = new { success = false, message = ex.InnerException.Message };
                }
                else
                {
                    data = new { success = false, message = ex.Message + " Another reason why EF sucks" };
                }
                return Json(data);

            }

            return Json(data);
        }