Example #1
0
        public ActionResult Homework(HomeworkViewModel HVM)
        {
            checkLogin();

            HVM.groupSelectList = (IEnumerable <SelectListItem>)Session["groupSelectList"];
            HVM.typeSelectList  = (IEnumerable <SelectListItem>)Session["typeSelectList"];
            HVM.groupFilList    = (IEnumerable <SelectListItem>)Session["groupFilList"];
            HVM.typeFilList     = (IEnumerable <SelectListItem>)Session["typeFilList"];
            HVM.termFilList     = (IEnumerable <SelectListItem>)Session["termFilList"];

            bool result = true;

            //inactive deleted view item
            foreach (var i in HVM.inactiveList)
            {
                if (result && i > 1)
                {
                    result = false;
                    result = DBS.InactiveRecord("HOMEWORK", i, CP.userID);
                }
            }

            //add new work from new view item
            foreach (var n in HVM.viewList)
            {
                if (result && n.ID < 1)
                {
                    result = false;
                    HOMEWORK newWork = new HOMEWORK()
                    {
                        NAME          = n.name,
                        STUDENT_GROUP = n.group_id,
                        HOMEWORK_TYPE = n.type_id,
                        DUE_DATE      = n.date_due,
                        FULL_MARK     = n.full_mark,
                        ADD_BY        = CP.userID,
                        ADD_DATE      = DateTime.Now,
                        ACTIVE        = true
                    };

                    result = DBS.addRecord(newWork);
                }
            }

            ModelState.Clear();
            TempData["showForm"]  = true;
            TempData["showForm2"] = false;
            if (result)
            {
                TempData[Constant.msg_success] = "Changes have been saved";
            }
            else
            {
                TempData[Constant.msg_error] = "Changes have not been saved";
            }
            return(Homework(HVM.SelectedTerm, HVM.SelectedGroup, HVM.SelectedType, HVM));
        }
Example #2
0
        public ActionResult InactiveStudent(int?Class_id, int?student_id, int?term_id)
        {
            checkLogin();

            bool result = (Class_id > 0 && student_id > 0 && term_id > 0) ? DBS.InactiveRecord("STUDENT", (int)student_id, CP.userID) : false;

            if (result)
            {
                TempData[Constant.msg_success] = Constant.ChangeSucceed;
            }
            else
            {
                TempData[Constant.msg_error] = Constant.ChangeFailed;
            }
            return(_Student((int)Class_id, 0, (int)term_id));
        }
Example #3
0
        public ActionResult Merit(MeritsViewModel MVM)
        {
            checkLogin();
            MVM.TermList  = CP.termSelectList;
            MVM.userList  = CP.teacherSelectList;
            MVM.classList = classSelectList;

            // fields checking
            if (!ModelState.IsValid)
            {
                return(View("Merit", MVM));
            }

            //edit or create
            bool result = true;

            for (int m = 0; m < MVM.merits.Count; m++)
            {
                if (result)
                {
                    if (MVM.merits[m].ID < 1)
                    {
                        result = false;
                        result = DBS.addRecord(MVM.merits[m]);
                    }
                }
            }

            foreach (var i in MVM.inactiveList)
            {
                if (result && i > 0)
                {
                    result = false;
                    result = DBS.InactiveRecord("MERITS", i, CP.userID);
                }
            }

            ModelState.Clear();
            if (result)
            {
                TempData[Constant.msg_success] = Constant.ChangeSucceed;
            }
            else
            {
                TempData[Constant.msg_error] = Constant.ChangeFailed;
            }
            return(viewMerits(MVM.selectedTerm, MVM.selectedClass, MVM.selectedStudent));
        }
        public ActionResult InactiveUser(int id)
        {
            checkLogin();
            if (id > 0)
            {
                if (DBS.InactiveRecord("QE_USER", id, CP.userID))
                {
                    TempData[Constant.msg_success] = "User has been deleted";
                    List <QE_USER> userList = DBS.findActiveRecords <QE_USER>(); // regen userlist
                    Session["userList"] = userList;

                    UsersAndTeachersViewModel ViewModel = new UsersAndTeachersViewModel(userList, userList.FirstOrDefault());
                    return(View("UsersAndTeachers", ViewModel));
                }
                else
                {
                    TempData[Constant.msg_success] = "Failed to delete user";
                    return(UsersAndTeachers(id));
                }
            }
            return(UsersAndTeachers(id));
        }