Пример #1
0
        public ActionResult HomeworkType()
        {
            checkLogin();

            HomeworkTypeViewModel HTVM = new HomeworkTypeViewModel()
            {
                types = DBS.findActiveRecords <HOMEWORK_TYPE>()
            };

            return(View(HTVM));
        }
Пример #2
0
        public ActionResult InactiveType(HomeworkTypeViewModel HTVM, int type_id)
        {
            checkLogin();

            HTVM.types.Remove(HTVM.types.Where(h => h.ID == type_id).FirstOrDefault());

            if (type_id > 0)
            {
                HTVM.inactiveList.Add(type_id);
            }

            ModelState.Clear();
            TempData["showForm"] = true;
            return(View("HomeworkType", HTVM));
        }
Пример #3
0
        public ActionResult AddType(HomeworkTypeViewModel HTVM)
        {
            checkLogin();

            HTVM.newType.ID       = GS.getNewID();
            HTVM.newType.ADD_BY   = CP.userID;
            HTVM.newType.ADD_DATE = DateTime.Now;
            HTVM.newType.ACTIVE   = true;

            HTVM.types.Add(HTVM.newType);
            HTVM.newType = new HOMEWORK_TYPE();

            ModelState.Clear();
            TempData["showForm"] = true;
            return(View("HomeworkType", HTVM));
        }
Пример #4
0
        public ActionResult HomeworkType(HomeworkTypeViewModel HTVM)
        {
            checkLogin();

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

            //edit or create
            bool result = true;

            for (int h = 0; h < HTVM.types.Count; h++)
            {
                if (result)
                {
                    if (HTVM.types[h].ID < 1)
                    {
                        result = false;
                        result = DBS.addRecord(HTVM.types[h]);
                    }
                }
            }

            foreach (var r in HTVM.inactiveList)
            {
                if (result && r > 0)
                {
                    result = false;
                    result = DBS.InactiveRecord("HOMEWORK_TYPE", r, CP.userID);
                }
            }

            ModelState.Clear();
            if (result)
            {
                TempData[Constant.msg_success] = Constant.ChangeSucceed;
            }
            else
            {
                TempData[Constant.msg_error] = Constant.ChangeFailed;
            }
            return(HomeworkType());
        }