Beispiel #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            ArticleSubcategory articleSubcategory = db.Subcategories.Find(id);

            db.Subcategories.Remove(articleSubcategory);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #2
0
 public ActionResult Edit([Bind(Include = "SubcategoryId,SubcategoryName,CategoryId")] ArticleSubcategory articleSubcategory)
 {
     if (ModelState.IsValid)
     {
         db.Entry(articleSubcategory).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId", "CategoryName", articleSubcategory.CategoryId);
     return(View(articleSubcategory));
 }
Beispiel #3
0
        public ActionResult Create([Bind(Include = "SubcategoryId,SubcategoryName,CategoryId")] ArticleSubcategory articleSubcategory)
        {
            if (ModelState.IsValid)
            {
                db.Subcategories.Add(articleSubcategory);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId", "CategoryName", articleSubcategory.CategoryId);
            return(View(articleSubcategory));
        }
        public ActionResult SubCategoryFilter(int categoryID)
        {
            var data = db.Subcategories.Where(s => s.CategoryId == categoryID).Select(s => new { s.SubcategoryId, s.SubcategoryName }).Distinct().ToList();
            List <ArticleSubcategory> subcategoryList = new List <ArticleSubcategory>();

            foreach (var item in data)
            {
                ArticleSubcategory obj = new ArticleSubcategory();
                obj.SubcategoryId   = item.SubcategoryId;
                obj.SubcategoryName = item.SubcategoryName;
                subcategoryList.Add(obj);
            }
            return(Json(subcategoryList, JsonRequestBehavior.AllowGet));
        }
Beispiel #5
0
        // GET: ArticleSubcategories/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ArticleSubcategory articleSubcategory = db.Subcategories.Find(id);

            if (articleSubcategory == null)
            {
                return(HttpNotFound());
            }
            return(View(articleSubcategory));
        }
Beispiel #6
0
        // GET: ArticleSubcategories/Delete/5
        public ActionResult Delete(int?id)
        {
            if (this.Session["User"] == null)
            {
                return(RedirectToAction("Login", "Users"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ArticleSubcategory articleSubcategory = db.Subcategories.Find(id);

            if (articleSubcategory == null)
            {
                return(HttpNotFound());
            }
            return(View(articleSubcategory));
        }
Beispiel #7
0
        // GET: ArticleSubcategories/Edit/5
        public ActionResult Edit(int?id)
        {
            if (this.Session["User"] == null)
            {
                return(RedirectToAction("Login", "Users"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ArticleSubcategory articleSubcategory = db.Subcategories.Find(id);

            if (articleSubcategory == null)
            {
                return(HttpNotFound());
            }
            ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId", "CategoryName", articleSubcategory.CategoryId);
            return(View(articleSubcategory));
        }