예제 #1
0
        public ActionResult AddEditClass(ClassListViewModel model)
        {
            FillAllDropdowns();

            string strSuccessMsg = string.Empty;
            string strErrorMsg = string.Empty;

            if (model != null && model.Class != null)
            {
                if (string.IsNullOrEmpty(model.Class.ClassID))
                {
                    strSuccessMsg = ClassRes.MsgAddSuccess;
                    strErrorMsg = ClassRes.MsgAddError;
                }
                else
                {
                    strSuccessMsg = ClassRes.MsgEditSuccess;
                    strErrorMsg = ClassRes.MsgEditError;
                }

                int i = _ClassService.AddEdit(model.Class);

                if (i <= 0)
                {
                    TempData["err"] = strErrorMsg;
                }
                else
                {
                    TempData["msg"] = strSuccessMsg;
                }
            }

            return RedirectToAction("ManageClass", "Class");
        }
예제 #2
0
        public ActionResult AddEditClass(string pClassID)
        {
            FillAllDropdowns();

            User objUser = null;
            if (eSchoolSession.IsInSession(SessionKeys.CurrentUser))
                objUser = (User)eSchoolSession.GetDirectValue(SessionKeys.CurrentUser);

            ClassListViewModel model = new ClassListViewModel();
            model.Class = new Class();

            if (ModelState.IsValid)
            {
                if (!string.IsNullOrEmpty(pClassID))
                {
                    model.Class.ClassID = pClassID;
                    model.Class = _ClassService.Get(model.Class);
                }
            }

            return PartialView("_AddEditClass", model);
        }
예제 #3
0
        public ActionResult ManageClassSubjects(ClassListViewModel model)
        {
            User objUser = null;
            if (eSchoolSession.IsInSession(SessionKeys.CurrentUser))
                objUser = (User)eSchoolSession.GetDirectValue(SessionKeys.CurrentUser);

            if (model.ClassSubjects == null)
            {
                model.ClassSubjects = new ClassSubjects();
            }

            if (model.ClassSubjectsList == null)
            {
                model.ClassSubjectsList = new List<ClassSubjects>();
            }

            List<ClassSubjects> lst = new List<ClassSubjects>();
            lst = _IClassSubjectsService.GetAll(model.ClassSubjects).ToList();
            if (lst != null && lst.Count > 0)
            {
                int cnt = 0;
                foreach (var singleRecord in lst.Select(x => new { x.ClassID, x.ClassName }).Distinct().ToList())
                {
                    if (singleRecord.ClassID == null)
                        continue;
                    string csvSubjects = "";
                    cnt = 0;
                    var lstSubjs = lst.Where(x => x.ClassID == singleRecord.ClassID).ToList();
                    foreach (ClassSubjects singleSubject in lstSubjs)
                    {
                        if (cnt == 0)
                        {
                            ++cnt;
                            csvSubjects = singleSubject.SubjectName;
                        }
                        else
                        {
                            csvSubjects += ", " + singleSubject.SubjectName;
                        }
                    }
                    model.ClassSubjectsList.Add(new ClassSubjects() { ClassID = singleRecord.ClassID, ClassName = singleRecord.ClassName, Subjects = csvSubjects });
                }
            }
            return View(model);
        }
예제 #4
0
        public ActionResult ManageClass(ClassListViewModel model)
        {
            User objUser = null;
            if (eSchoolSession.IsInSession(SessionKeys.CurrentUser))
                objUser = (User)eSchoolSession.GetDirectValue(SessionKeys.CurrentUser);

            if (model.Class == null)
            {
                model.Class = new Class();
            }

            if (!string.IsNullOrEmpty(model.Class.sort))
            {
                model.Class.SortExp = model.Class.sort + " " + model.Class.sortdir;
            }

            if (model.Class.PageSize == 0)
            {
                int PageSize = Convert.ToInt32(ConfigurationManager.AppSettings["PageSize"]);
                model.Class.PageSize = PageSize;
            }

            if (model.Class.PageIndex == 0)
            {
                model.Class.PageIndex = 1;
            }
            model.ClassList = new List<Class>();
            model.Class.TotalCount = 0;

            model.ClassList = _ClassService.GetAll(model.Class).ToList();
            Lookup entity = new Lookup();

            if (model.ClassList != null && model.ClassList.Count > 0)
            {
                int TotalCount = model.ClassList[0].TotalCount;
                model.Class.TotalCount = TotalCount;
            }

            return View(model);
        }
예제 #5
0
        public ActionResult DeleteClass(string pClassID)
        {
            if (!string.IsNullOrEmpty(pClassID))
            {
                ClassListViewModel model = new ClassListViewModel();
                model.Class = new Class();
                model.Class.ClassID = pClassID;
                int i = _ClassService.Delete(model.Class);

                if (i <= 0)
                    TempData["err"] = ClassRes.MsgDeleteError;
                else
                    TempData["msg"] = ClassRes.MsgDeleteSuccess;
            }

            return RedirectToAction("ManageClass", "Class");
        }
예제 #6
0
        public ActionResult AddEditClassSubjects(ClassListViewModel model)
        {
            _IClassSubjectsService.DeleteAllClassSubjects(new ClassSubjects() { ClassID = model.ClassSubjects.ClassID });

            string[] csvSubjects = model.ClassSubjects.Subjects.Split(',');

            foreach (string singleSubject in csvSubjects)
            {
                if (string.IsNullOrEmpty(singleSubject))
                    continue;

                ClassSubjects obj = new ClassSubjects();
                obj.SubjectID = singleSubject.Trim();
                obj.ClassID = model.ClassSubjects.ClassID;
                obj.ClassSubjectID = Utility.GeneratorUniqueId("CLSSUB_");
                _IClassSubjectsService.AddEdit(obj);
            }

            return RedirectToAction("ManageClassSubjects", "Class");
        }
예제 #7
0
        public ActionResult AddEditClassSubjects(string ClassID)
        {
            ClassListViewModel model = new ClassListViewModel();
            model.ClassSubjects = new ClassSubjects();
            model.ClassSubjectsList = new List<ClassSubjects>();

            if (!string.IsNullOrEmpty(ClassID))
            {
                model.ClassSubjects.ClassID = ClassID;
            }

            model.ClassSubjectsList = _IClassSubjectsService.GetAll(model.ClassSubjects).ToList();

            List<Class> lstClass = _ClassService.GetAllForLookup(new Class()).ToList();
            SelectList retList = null;
            retList = new SelectList(lstClass, Class_Constant.CLASS_ID, Class_Constant.CLASS_NAME, ClassID);

            ViewBag.ClassList = retList;
            return PartialView("_AddEditClassSubjects", model);
        }