public int AddEdit(StudentsClass entity)
        {
            int i = 0;

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

            if (entity != null && string.IsNullOrEmpty(entity.SchoolID))
            {
                if (objUser != null && !string.IsNullOrEmpty(objUser.SchoolID))
                    entity.SchoolID = objUser.SchoolID;
            }

            if (string.IsNullOrEmpty(entity.StudentClassID))
            {
                entity.StudentClassID = Utility.GeneratorUniqueId(ID_PREFIX_CONSTANTS.STUDENTS_CLASS_ID_PREFIX);

                if (objUser != null && !string.IsNullOrEmpty(objUser.UserID))
                {
                    entity.CreatedByID = objUser.UserID;
                    entity.ModifiedByID = objUser.UserID;
                }
                else
                {
                    entity.CreatedByID = "1";
                    entity.ModifiedByID = "1";
                }
            }
            else
            {
                if (objUser != null && !string.IsNullOrEmpty(objUser.UserID))
                    entity.ModifiedByID = objUser.UserID;
                else
                    entity.ModifiedByID = "1";
            }

            string[] addParams = { StudentsClass_Constant.STUDENT_CLASS_ID,
                                   StudentsClass_Constant.SCHOOL_ID,
                                   StudentsClass_Constant.STUDENT_ID,
                                        StudentsClass_Constant.ACADEMIC_YEAR_ID,
                                        StudentsClass_Constant.CLASS_ID,
                                        StudentsClass_Constant.SECTION_ID,
                                        StudentsClass_Constant.BATCH_ID,
                                        StudentsClass_Constant.ROLL_NO,
                                        StudentsClass_Constant.IS_CURRENT_CLASS,
                                        StudentsClass_Constant.CREATED_BY_ID,
                                        StudentsClass_Constant.MODIFIED_BY_ID
                                        };

            i = _StudentsClassRepository.ExecuteNonQuery(entity, addParams, StudentsClass_Constant.SPROC_STUDENTSCLASS_UPS);

            return i;
        }
 public StudentsClass Get(StudentsClass entity)
 {
     string[] addParams = { StudentsClass_Constant.STUDENT_CLASS_ID };
     return _StudentsClassRepository.Get(entity, addParams, StudentsClass_Constant.SPROC_STUDENTSCLASS_SEL);
 }
        public int Delete(StudentsClass entity)
        {
            int i = 0;

            string[] addParams = { StudentsClass_Constant.STUDENT_CLASS_ID };
            i = _StudentsClassRepository.ExecuteNonQuery(entity, addParams, StudentsClass_Constant.SPROC_STUDENTSCLASS_DEL);

            return i;
        }
        public int UpdateCurrentClassRollNo(StudentsClass entity)
        {
            int i = 0;

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

            if (entity != null && string.IsNullOrEmpty(entity.SchoolID))
            {
                if (objUser != null && !string.IsNullOrEmpty(objUser.SchoolID))
                    entity.SchoolID = objUser.SchoolID;

                if (objUser != null && !string.IsNullOrEmpty(objUser.UserID))
                    entity.ModifiedByID = objUser.UserID;
                else
                    entity.ModifiedByID = "1";
            }

            string[] addParams = { StudentsClass_Constant.SCHOOL_ID,
                                 StudentsClass_Constant.STUDENT_ID,
                                 StudentsClass_Constant.ACADEMIC_YEAR_ID,
                                 StudentsClass_Constant.CLASS_ID,
                                 StudentsClass_Constant.SECTION_ID,
                                 StudentsClass_Constant.BATCH_ID,
                                 StudentsClass_Constant.ROLL_NO,
                                 StudentsClass_Constant.MODIFIED_BY_ID};

            i = _StudentsClassRepository.ExecuteNonQuery(entity, addParams, StudentsClass_Constant.SPROC_STUDENTSCLASS_UPS_CURRENT_CLASS_ROLLNO);

            return i;
        }
        public int SetAllCurrentClassFalse(StudentsClass entity)
        {
            int i = 0;

            string[] addParams = {  Student_Constant.STUDENT_ID};

            i = _StudentsClassRepository.ExecuteNonQuery(entity, addParams, StudentsClass_Constant.SPROC_STUDENTSCLASS_UPS_SET_ALL_CURRENT_CLASS_FALSE);

            return i;
        }
 public object GetScalar(StudentsClass entity)
 {
     throw new NotImplementedException();
 }
        public IEnumerable<StudentsClass> GetAll(StudentsClass entity)
        {
            User objUser = null;
            if (eSchoolSession.IsInSession(SessionKeys.CurrentUser))
                objUser = (User)eSchoolSession.GetDirectValue(SessionKeys.CurrentUser);

            if (objUser != null && !string.IsNullOrEmpty(objUser.SchoolID))
                entity.SchoolID = objUser.SchoolID;

            string[] addParams = { Constants.PAGEINDEX, Constants.PAGESIZE, Constants.SORTEXP,
                                 StudentsClass_Constant.SCHOOL_ID,
                                 StudentsClass_Constant.STUDENT_ID};
            return _StudentsClassRepository.GetAll(entity, addParams, StudentsClass_Constant.SPROC_STUDENTSCLASS_LSTALL);
        }
        public ActionResult AssignRollNo(StudentsListViewModel model, string submit)
        {
            FillAllDropdownsForClassAssignment();

            if (submit == StudentsClassRes.Save)
            {
                if (model.StudentList != null && model.StudentList.Count > 0)
                {
                    foreach (Student objStudent in model.StudentList)
                    {
                        if (objStudent.CurrentRollNo != 0)
                        {
                            Student objGetStudent = new Student();
                            objGetStudent.StudentID = objStudent.StudentID;
                            objGetStudent = _StudentService.Get(objGetStudent);

                            if (objGetStudent != null && !string.IsNullOrEmpty(objGetStudent.FirstName))
                            {
                                objStudent.CurrentAcademicYearID = objGetStudent.CurrentAcademicYearID;
                                objStudent.CurrentClassID = objGetStudent.CurrentClassID;
                                objStudent.CurrentSectionID = objGetStudent.CurrentSectionID;
                                objStudent.CurrentBatchID = objGetStudent.CurrentBatchID;
                                _StudentService.UpdateStudentsClassRollNo(objStudent);

                                StudentsClass obj = new StudentsClass();
                                obj.StudentID = objStudent.StudentID; ;
                                obj.AcademicYearID = objGetStudent.CurrentAcademicYearID;
                                obj.ClassID = objGetStudent.CurrentClassID;
                                obj.SectionID = objGetStudent.CurrentSectionID;
                                obj.BatchID = objGetStudent.CurrentBatchID;
                                obj.RollNo = objGetStudent.CurrentRollNo;

                                _StudentsClassService.UpdateCurrentClassRollNo(obj);
                            }

                        }
                    }
                }
            }

            if (model.Student == null)
                model.Student = new Student();

            if (model.StudentsClass == null)
                model.StudentsClass = new StudentsClass();

            model.StudentList = new List<Student>();
            model.StudentList = _StudentService.GetAllStudentForClassAssignment(model.Student).ToList();

            return View(model);
        }
        public ActionResult AssignStudentToClass(StudentsListViewModel model, string submit, string[] ids)
        {
            FillAllDropdownsForClassAssignment();

            if (submit == StudentsClassRes.Save)
            {
                if (model.StudentsClass.IsCurrentClass)
                {
                    foreach (string strStudentID in ids)
                    {
                        StudentsClass obj = new StudentsClass();
                        obj.StudentID = strStudentID;
                        obj.AcademicYearID = model.StudentsClass.AcademicYearID;
                        obj.ClassID = model.StudentsClass.ClassID;
                        obj.SectionID = model.StudentsClass.SectionID;
                        obj.BatchID = model.StudentsClass.BatchID;
                        obj.IsCurrentClass = model.StudentsClass.IsCurrentClass;

                        _StudentsClassService.SetAllCurrentClassFalse(obj);
                        _StudentsClassService.AddEdit(obj);

                        Student objStudent = new Student();
                        objStudent.StudentID = strStudentID;
                        objStudent.CurrentAcademicYearID = model.StudentsClass.AcademicYearID;
                        objStudent.CurrentClassID = model.StudentsClass.ClassID;
                        objStudent.CurrentSectionID = model.StudentsClass.SectionID;
                        objStudent.CurrentBatchID = model.StudentsClass.BatchID;

                        _StudentService.UpdateStudentsClassRollNo(objStudent);

                    }
                }
            }

            if (model.Student == null)
                model.Student = new Student();

            if (model.StudentsClass == null)
                model.StudentsClass = new StudentsClass();

            model.StudentList = new List<Student>();
            model.StudentList = _StudentService.GetAllStudentForClassAssignment(model.Student).ToList();

            return View(model);
        }