Ejemplo n.º 1
0
        public ActionResult Create(ClassesViewModels collection)
        {
            try
            {
                if (HelperClass.account != "Admin")
                {
                    return(RedirectToAction("Index", "Home"));
                }
                DB37Entities db = new DB37Entities();
                if (db.Classtbls.Any(t => t.Section.Equals(collection.Name)))
                {
                    ViewBag.warn = "Class Already Exist";
                    return(View());
                }

                Classtbl c = new Classtbl();
                c.Section = collection.Name;
                db.Classtbls.Add(c);
                db.SaveChanges();
                return(RedirectToAction("Index", "Class"));
            }
            catch
            {
                return(View());
            }
        }
Ejemplo n.º 2
0
        // GET: Class
        public ActionResult Index()
        {
            if (HelperClass.account != "Admin")
            {
                return(RedirectToAction("Index", "Home"));
            }
            ClassesViewModels.ClassesList.Clear();
            DB37Entities db = new DB37Entities();

            foreach (Classtbl c in db.Classtbls)
            {
                ClassesViewModels a = new ClassesViewModels();
                a.Id   = c.Id;
                a.Name = c.Section;
                ClassesViewModels.ClassesList.Add(a);
            }
            return(View(ClassesViewModels.ClassesList));
        }
Ejemplo n.º 3
0
        public ActionResult Edit(int id, ClassesViewModels collection)
        {
            try
            {
                // TODO: Add update logic here

                if (HelperClass.account != "Admin")
                {
                    return(RedirectToAction("Index", "Home"));
                }
                DB37Entities db = new DB37Entities();
                db.Classtbls.Find(id).Section = collection.Name;
                db.SaveChanges();
                return(RedirectToAction("Index", "Class"));
            }
            catch
            {
                return(View());
            }
        }