Пример #1
0
        public IList <ClassStatsInfo> GetClassesStatsForStudent(int studentId, int gradingPeriodId, ClassSortType?sortType)
        {
            Trace.Assert(Context.SchoolYearId.HasValue);
            if (!(BaseSecurity.IsDistrictOrTeacher(Context) || studentId == Context.PersonId))
            {
                throw new ChalkableSecurityException();
            }

            IList <SectionSummaryForStudent> iNowRes;

            try
            {
                iNowRes = ConnectorLocator.ClassesDashboardConnector.GetSectionSummaryForStudent(Context.SchoolYearId.Value, studentId, gradingPeriodId);
            }
            catch (ChalkableSisNotSupportVersionException)
            {
                var gp           = ServiceLocator.GradingPeriodService.GetGradingPeriodById(gradingPeriodId);
                var chalkableRes = DoRead(u => new ClassDataAccess(u).GetStudentClasses(Context.SchoolYearId.Value, studentId, gp.MarkingPeriodRef));
                return(SortClassesStats(chalkableRes.Select(ClassStatsInfo.Create), sortType).ToList());
            }
            using (var u = Read())
            {
                var classesIds    = iNowRes.Select(x => x.SectionId).ToList();
                var classes       = new ClassDataAccess(u).GetByIds(classesIds);
                var classTeachers = new ClassTeacherDataAccess(u).GetClassTeachers(classesIds);
                var res           = ClassStatsInfo.Create(iNowRes, classes, classTeachers);
                return(SortClassesStats(res, sortType).ToList());
            }
        }
Пример #2
0
        public void DeleteClass(DeleteClassRequest request)
        {
            if (request != null)
            {
                var dataAccess = new ClassDataAccess(request.Context);

                var item = dataAccess.GetById(request.IdClass);

                dataAccess.Delete(item.FirstOrDefault());
            }
        }
Пример #3
0
        public IActionResult GradeCreate(int?value)
        {
            //dropwdown list
            List <SelectListItem> items = new List <SelectListItem>();
            SelectListItem        item1 = new SelectListItem()
            {
                Text = "Select Option", Value = "null"
            };
            SelectListItem item2 = new SelectListItem()
            {
                Text = "Grade 9", Value = "9"
            };
            SelectListItem item3 = new SelectListItem()
            {
                Text = " Grade 10", Value = "10"
            };

            items.Add(item1);
            items.Add(item2);
            items.Add(item3);
            ViewBag.Options = items;

            if (value != null)
            {
                ViewBag.Value = value;

                var currentYear = DateTime.Now.Year;
                ViewBag.CurrentYear = currentYear;

                var lastYear = DateTime.Now.Year - 1;
                ViewBag.LastYear = lastYear;


                List <studentModel> students = new List <studentModel>();
                students = ClassDataAccess.listUngradedStudents(Convert.ToInt32(value));

                //ViewBag.Students = students;

                List <studentModel> allstudents = new List <studentModel>();
                //allstudents = StudentDataAccess.SelectStudentByGrade(Convert.ToInt32(value));
                foreach (var student in students)
                {
                    allstudents.AddRange(StudentDataAccess.SelectStudent(student.StudentId));
                }
                ViewBag.Students = allstudents;


                List <classModel> classes = new List <classModel>();
                classes         = ClassDataAccess.SelectClass(Convert.ToInt32(value));
                ViewBag.Classes = classes;
            }
            return(View());
        }
Пример #4
0
        public Class UpdateClass(UpdateClassRequest request)
        {
            Class item = null;

            if (request != null && request.Class != null)
            {
                var dataAccess = new ClassDataAccess(request.Context);

                item = dataAccess.Update(request.Class);
            }

            return(item);
        }
Пример #5
0
        public IActionResult Index()
        {
            List <studentModel> allstudents = new List <studentModel>();

            allstudents      = StudentDataAccess.SelectStudentByGrade(9);
            ViewBag.Students = allstudents;

            List <gradeModel> grades = new List <gradeModel>();

            grades         = ClassDataAccess.SelectGrade(9);
            ViewBag.Grades = grades;

            return(View());
        }
 public ActionResult InsertClass(Class c)
 {
     if (ModelState.IsValid) //checking model is valid or not
     {
         ClassDataAccess objDB  = new ClassDataAccess();
         string          result = objDB.insertClass(c);
         ViewData["result"] = result;
         ModelState.Clear(); //clearing model
         return(View());
     }
     else
     {
         ModelState.AddModelError("", "Error in saving data");
         return(View());
     }
 }
Пример #7
0
        public Class GetClassById(GetClassByIdRequest request)
        {
            Class item = null;

            if (request != null)
            {
                var dataAccess = new ClassDataAccess(request.Context);

                var classQuery = dataAccess.GetById(request.IdClass);

                classQuery = classQuery.Include(c => c.Academy);

                item = classQuery.FirstOrDefault();
            }

            return(item);
        }
Пример #8
0
        public List <Class> GetAllClasses(GetAllClassesRequest request)
        {
            List <Class> classes = null;

            if (request != null)
            {
                var dataAccess = new ClassDataAccess(request.Context);

                var classesQuery = dataAccess.GetAll();

                classesQuery = classesQuery.Include(c => c.Academy);

                classes = classesQuery.ToList();
            }

            return(classes);
        }
Пример #9
0
        private bool CanStudentSendMessage(int personId, UnitOfWork uow)
        {
            Trace.Assert(Context.PersonId.HasValue);
            Trace.Assert(Context.SchoolLocalId.HasValue);

            bool canSend      = false;
            var  toPersonRole = ServiceLocator.PersonService.GetPersonRole(personId);

            var currPersonClasses = new ClassDataAccess(uow).GetStudentClasses(Context.SchoolYearId.Value,
                                                                               Context.PersonId.Value, null);

            if (toPersonRole == CoreRoles.TEACHER_ROLE && Context.TeacherStudentMessaginEnabled)
            {
                if (Context.TeacherClassMessagingOnly)
                {
                    var toPersonClasses = new ClassDataAccess(uow).GetTeacherClasses(Context.SchoolYearId.Value,
                                                                                     personId, null);

                    canSend = currPersonClasses.Any(x => toPersonClasses.Any(y => x.Id == y.Id));
                }
                else
                {
                    return(true);
                }
            }

            if (toPersonRole == CoreRoles.STUDENT_ROLE)
            {
                if (Context.StudentMessagingEnabled)
                {
                    canSend = true;
                    if (Context.StudentClassMessagingOnly)
                    {
                        var toPersonClasses = new ClassDataAccess(uow).GetStudentClasses(Context.SchoolYearId.Value,
                                                                                         personId, null);

                        canSend = currPersonClasses.Any(x => toPersonClasses.Any(y => x.Id == y.Id));
                    }
                }
            }

            return(canSend);
        }
Пример #10
0
        public IList <ClassStatsInfo> GetClassesStats(int schoolYearId, int?start, int?count, string filter, int?teacherId, ClassSortType?sortType)
        {
            start = start ?? 0;
            count = count ?? int.MaxValue;
            var iNowSortType = EnumMapperFactory.GetMapper <ClassSortType, SectionSummarySortOption>().Map(sortType ?? ClassSortType.ClassAsc);

            IList <SectionSummary> iNowRes;

            try
            {
                if (teacherId.HasValue)
                {
                    iNowRes = ConnectorLocator.ClassesDashboardConnector.GetSectionSummariesByTeacher(schoolYearId,
                                                                                                      teacherId.Value, Context.NowSchoolYearTime, start.Value + 1, start.Value + count.Value, filter, iNowSortType);
                }
                else
                {
                    iNowRes = ConnectorLocator.ClassesDashboardConnector.GetSectionsSummaries(schoolYearId,
                                                                                              Context.NowSchoolYearTime, start.Value + 1, start.Value + count.Value, filter, iNowSortType);
                }
            }
            catch (ChalkableSisNotSupportVersionException)
            {
                var chalkableRes = DoRead(u => new ClassDataAccess(u).GetClassesBySchoolYear(schoolYearId, start.Value, count.Value,
                                                                                             filter, teacherId, (int?)sortType));
                return(chalkableRes.Select(ClassStatsInfo.Create).ToList());
            }

            using (var u = Read())
            {
                var classesIds    = iNowRes.Select(x => x.SectionId).ToList();
                var classes       = new ClassDataAccess(u).GetByIds(classesIds);
                var classTeachers = new ClassTeacherDataAccess(u).GetClassTeachers(classesIds);

                return(ClassStatsInfo.Create(iNowRes, classes, classTeachers));
            }
        }
Пример #11
0
        public void FixRoomDelete(Guid districtid)
        {
            District d;
            var      mcs = "Data Source=yqdubo97gg.database.windows.net;Initial Catalog=ChalkableMaster;UID=chalkableadmin;Pwd=Hellowebapps1!";

            using (var uow = new UnitOfWork(mcs, false))
            {
                var da = new DistrictDataAccess(uow);
                d = da.GetById(districtid);
            }

            var cs = String.Format("Data Source={0};Initial Catalog={1};UID=chalkableadmin;Pwd=Hellowebapps1!", d.ServerUrl, d.Id);
            IList <SyncVersion> versions;

            using (var uow = new UnitOfWork(cs, true))
            {
                versions = (new SyncVersionDataAccess(uow)).GetAll();
                uow.Commit();
            }

            var cl           = ConnectorLocator.Create("Chalkable", d.SisPassword, d.SisUrl);
            var deletedRooms = (cl.SyncConnector.GetDiff(typeof(Room), versions.First(x => x.TableName == "Room").Version) as SyncResult <Room>).Deleted;

            using (var uow = new UnitOfWork(cs, true))
            {
                var da      = new ClassDataAccess(uow);
                var all     = da.GetAll();
                var classes = all.Where(x => deletedRooms.Any(y => x.RoomRef == y.RoomID)).ToList();
                foreach (var @class in classes)
                {
                    @class.RoomRef = null;
                }
                da.Update(classes.ToList());
                uow.Commit();
            }
        }
Пример #12
0
        public IList <TeacherStatsInfo> GetTeachersStats(int schoolYearId, string filter, int?start, int?count, TeacherSortType?sortType)
        {
            start = start ?? 0;
            count = count ?? int.MaxValue;
            var iNowSortType = EnumMapperFactory.GetMapper <TeacherSortType, SectionSummarySortOption>()
                               .Map(sortType ?? TeacherSortType.TeacherAsc);

            try
            {
                var iNowRes = ConnectorLocator.ClassesDashboardConnector.GetTeachersSummaries(schoolYearId,
                                                                                              Context.NowSchoolYearTime, start.Value + 1, start.Value + count.Value, filter, iNowSortType);

                return(iNowRes.Select(TeacherStatsInfo.Create).ToList());
            }
            catch (ChalkableSisNotSupportVersionException)
            {
                using (var u = Read())
                {
                    var teachers = new StaffDataAccess(u).GetShortStaffSummary(schoolYearId, filter, start.Value, count.Value, (int?)sortType);
                    var classes  = new ClassDataAccess(u).GetClassesByTeachers(schoolYearId, teachers.Select(x => x.Id).ToList());
                    return(TeacherStatsInfo.Create(teachers, classes));
                }
            }
        }
Пример #13
0
 public IActionResult GradeCreate(gradeModel m)
 {
     ClassDataAccess.CreateNewGrade(m);
     return(RedirectToAction("Index"));
 }
Пример #14
0
 public IActionResult ClassCreate(classModel m)
 {
     ClassDataAccess.CreateNew(m);
     return(RedirectToAction("Index"));
 }
Пример #15
0
 public ClassRules(Context contextDB)
 {
     DataAccess = new ClassDataAccess(contextDB);
 }
Пример #16
0
 public void UIMethod()
 {
     ClassDataAccess.DatMethod();
 }