public ActionResult EditCategory(Category model)
        {
            EasyServiceEntities easyServiceEntities = new EasyServiceEntities();

            easyServiceEntities.Entry(model).State = EntityState.Modified;
            easyServiceEntities.SaveChanges();
            return(RedirectToAction("ListCategory"));
        }
        public ActionResult AddCategory(Category model)
        {
            EasyServiceEntities easyServiceEntities = new EasyServiceEntities();

            easyServiceEntities.Categories.Add(model);
            easyServiceEntities.SaveChanges();
            return(RedirectToAction("ListCategory"));
        }
Example #3
0
        public ActionResult EditListing(VendorListing model)
        {
            EasyServiceEntities easyServiceEntities = new EasyServiceEntities();

            easyServiceEntities.Entry(model).State = EntityState.Modified;
            easyServiceEntities.SaveChanges();
            return(RedirectToAction("ViewListing"));
        }
        public ActionResult DeleteSubCategory(int Id)
        {
            EasyServiceEntities easyServiceEntities = new EasyServiceEntities();
            SubCategory         subCategory         = easyServiceEntities.SubCategories.Where(a => a.Id == Id).FirstOrDefault();

            easyServiceEntities.SubCategories.Remove(subCategory);
            easyServiceEntities.SaveChanges();
            return(RedirectToAction("ListSubCategory"));
        }
Example #5
0
        public ActionResult DeleteListing(int Id)
        {
            EasyServiceEntities easyServiceEntities = new EasyServiceEntities();
            VendorListing       vendorListing       = easyServiceEntities.VendorListings.Where(a => a.Id == Id).FirstOrDefault();

            easyServiceEntities.VendorListings.Remove(vendorListing);
            easyServiceEntities.SaveChanges();
            return(RedirectToAction("ViewListing"));
        }
Example #6
0
        public ActionResult AddListing(VendorListing model)
        {
            EasyServiceEntities easyServiceEntities = new EasyServiceEntities();

            var userId = easyServiceEntities.AspNetUsers.Where(a => a.UserName == User.Identity.Name).Select(x => x.Id).FirstOrDefault();

            model.UserId = userId;
            easyServiceEntities.VendorListings.Add(model);
            int c = easyServiceEntities.SaveChanges();

            return(RedirectToAction("ViewListing"));
        }
        public ActionResult DeleteCategory(int id)
        {
            EasyServiceEntities easyServiceEntities = new EasyServiceEntities();

            bool subCategory = easyServiceEntities.SubCategories.Where(a => a.CategoryId == id).Any();

            if (!subCategory)
            {
                Category category = easyServiceEntities.Categories.Where(a => a.Id == id).FirstOrDefault();
                easyServiceEntities.Categories.Remove(category);
                easyServiceEntities.SaveChanges();

                return(RedirectToAction("ListCategory"));
            }
            else
            {
                TempData["errorMessage"] = "<script>alert('There are Subcategory associated with this category, please delete those subcategory first');</script>";
                return(RedirectToAction("ListCategory"));
            }
        }