예제 #1
0
        public async Task <List <StandardMasterBM> > GetAllStandards(int RowCount)
        {
            List <StandardMasterBM> result = new List <StandardMasterBM>();
            var oStandards = await _DBStandardMasterRepository.GetAllStandards(RowCount).ConfigureAwait(false);

            if (oStandards != null && oStandards.Count > 0)
            {
                foreach (var item in oStandards)
                {
                    result.Add(new StandardMasterBM
                    {
                        Id        = item.Id,
                        Name      = item.Name,
                        Action    = item.Id.ToString(),
                        CreatedOn = item.CreatedOn,
                        CreatedBy = item.CreatedBy
                    });
                }
            }
            return(result);
        }
예제 #2
0
        public async Task <CommonResponce> GetClassroomVM(ClassRoomDetailsVM TempVModel)
        {
            bool isValid = true;

            TempVModel.Subjects = new List <AppSelectListItem>();
            var oSubject = await _DBSubjectRepository.GetAllSubjects(500).ConfigureAwait(false);

            if (oSubject != null && oSubject.Count > 0)
            {
                foreach (var item in oSubject)
                {
                    AppSelectListItem AppSItem = new AppSelectListItem {
                        Value = item.Id.ToString(), Text = item.Name
                    };
                    TempVModel.Subjects.Add(AppSItem);
                }
                ;
            }
            TempVModel.Standards = new List <AppSelectListItem>();
            var oStandards = await _DBStandardMasterRepository.GetAllStandards(500).ConfigureAwait(false);

            if (oStandards != null && oStandards.Count > 0)
            {
                foreach (var item in oStandards)
                {
                    AppSelectListItem AppSItem = new AppSelectListItem {
                        Value = item.Id.ToString(), Text = item.Name
                    };
                    TempVModel.Standards.Add(AppSItem);
                }
            }

            TempVModel.AllTeachers = await GetAllClassMembers(500, "teacher").ConfigureAwait(false); // new List<ClassMemberInfo>();

            TempVModel.AllStudents = await GetAllClassMembers(500, "student").ConfigureAwait(false); // new List<ClassMemberInfo>();

            if (TempVModel.Id > 0)
            {
                var oAssignTeachers = await _DBTeacherRepository.GetClassRoomTeachers(TempVModel.Id).ConfigureAwait(false);

                if (oAssignTeachers != null && oAssignTeachers.Count > 0)
                {
                    TempVModel.AsignTeacher = oAssignTeachers.Select(s => s.RegNo).ToArray();
                }

                var oAssignStudents = await _DBStudentRepository.GetClassRoomStudents(TempVModel.Id).ConfigureAwait(false);

                if (oAssignStudents != null && oAssignStudents.Count > 0)
                {
                    TempVModel.AsignStudent = oAssignStudents.Select(s => s.RegNo).ToArray();
                }

                var TempClassRoom = await _DBClassroomRepository.GetClassroomByClassroomId(TempVModel.Id);

                if (TempClassRoom != null)
                {
                    TempVModel.Description = TempClassRoom.Description;
                    TempVModel.RefId       = TempClassRoom.RefId;
                    TempVModel.Name        = TempClassRoom.Name;
                    TempVModel.SubjectId   = TempClassRoom.SubjectId;
                    TempVModel.StandardId  = TempClassRoom.StandardId;
                    TempVModel.Scheduler   = TempClassRoom.Scheduler.JSONStringToObject <ClassSchedule>();
                    TempVModel.ClassActivationThreshold = TempClassRoom.ClassActivationThreshold;
                }
            }
            else
            {
                TempVModel.Scheduler                = new ClassSchedule();
                TempVModel.Scheduler.StartDate      = new DateTime(DateTime.Now.Year, 1, 1);
                TempVModel.Scheduler.EndDate        = new DateTime(DateTime.Now.Year, 12, 31);
                TempVModel.Scheduler.StartTime      = DateTime.Now.ToString("h:mm tt");
                TempVModel.Scheduler.EndTime        = DateTime.Now.AddHours(1).ToString("hh:mm tt");
                TempVModel.ClassActivationThreshold = 60; //default value later may be read from settings
            }
            CommonResponce result = new CommonResponce {
                Stat = isValid, StatusMsg = (isValid ? "" : "Invalid Classroom Id"), StatusObj = null
            };

            return(result);
        }