public ActionResult EditCategory(int id)
        {
            MVCWebAppDbContext db = new MVCWebAppDbContext();

            var editCategory = db.tbl_Category.Find(id);

            return(View(editCategory));
        }
        public ActionResult EditCategory(tbl_Category category)
        {
            MVCWebAppDbContext db = new MVCWebAppDbContext();

            db.Entry(category).State = System.Data.Entity.EntityState.Modified;

            db.SaveChanges();

            return(RedirectToAction("ListCategory"));
        }
        public ActionResult ListCategory()
        {
            MVCWebAppDbContext db = new MVCWebAppDbContext();

            var categoryList = db.tbl_Category.ToList();

            //ViewBag.CategoryList = db.tbl_Category.ToList();

            return(View(categoryList));
        }
        // Implementing Delete Functionality

        public ActionResult DeleteCategory(int id)
        {
            MVCWebAppDbContext db = new MVCWebAppDbContext();

            var delCategoryID = db.tbl_Category.Find(id);

            db.tbl_Category.Remove(delCategoryID);

            db.SaveChanges();

            return(RedirectToAction("ListCategory"));
        }
        public ActionResult Category(tbl_Category category)
        {
            // Creates a Database Object
            MVCWebAppDbContext db = new MVCWebAppDbContext();

            // Using Database object refrence select table on which you want to perform action such as add, select, update, delete
            // Action takes the whole Object
            db.tbl_Category.Add(category);

            // After performing action you need to save changes to db using SaveChanges operation
            db.SaveChanges();

            // --------------------------------------------
            //ViewBag.CategoryName = name;                 |
            //ViewBag.CategoryDesc = description;          |
            // --------------------------------------------
            return(RedirectToAction("ListCategory"));
        }
示例#6
0
 public CampusService(MVCWebAppDbContext context)
 {
     _context = context;
 }
示例#7
0
 public StudentsService(MVCWebAppDbContext context)
 {
     _context = context;
 }