Пример #1
0
        public ActionResult _StudentGroupAndSubjects(GroupSubjectViewModel GSVM)
        {
            checkLogin();

            bool result = true;

            for (int i = 0; i < GSVM.GSs.Count; i++)
            {
                if (result)
                {
                    if (GSVM.GSs[i].Contain && GSVM.GSs[i].MapID < 1) // constains a map ID means its an existing record
                    {
                        STUDENT_GROUP_SUBJECT_LIST newMap = new STUDENT_GROUP_SUBJECT_LIST(0, GSVM.GSs[i].GroupID, GSVM.GSs[i].SubjectID, CP.userID, DateTime.Now, 0, Constant.DEF_DATETIME, true);
                        result = false;
                        result = DBS.addRecord(newMap);
                    }
                    else if (!GSVM.GSs[i].Contain && GSVM.GSs[i].MapID > 0) //not contain but have existing id means need to remove
                    {
                        result = false;
                        result = DBS.InactiveRecord("STUDENT_GROUP_SUBJECT_LIST", GSVM.GSs[i].MapID, CP.userID);
                    }
                }
            }

            ModelState.Clear();
            if (result)
            {
                TempData[Constant.msg_success] = Constant.ChangeSucceed;
            }
            else
            {
                TempData[Constant.msg_error] = Constant.ChangeFailed;
            }
            return(RedirectToAction("StudentGroupAndSubjects", "Student", new { term_id = GSVM.SelectedTerm, group_id = GSVM.GSs.FirstOrDefault().GroupID }));
        }
Пример #2
0
 public static int AddGroupSubjectMap(STUDENT_GROUP_SUBJECT_LIST newMap)
 {
     int newMap_id = WillORM.InsertRecord(newMap); return(newMap_id > 0 ? newMap_id : 0);
 }