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()); } }
public void DeleteClass(DeleteClassRequest request) { if (request != null) { var dataAccess = new ClassDataAccess(request.Context); var item = dataAccess.GetById(request.IdClass); dataAccess.Delete(item.FirstOrDefault()); } }
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()); }
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); }
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()); } }
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); }
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); }
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); }
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)); } }
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(); } }
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)); } } }
public IActionResult GradeCreate(gradeModel m) { ClassDataAccess.CreateNewGrade(m); return(RedirectToAction("Index")); }
public IActionResult ClassCreate(classModel m) { ClassDataAccess.CreateNew(m); return(RedirectToAction("Index")); }
public ClassRules(Context contextDB) { DataAccess = new ClassDataAccess(contextDB); }
public void UIMethod() { ClassDataAccess.DatMethod(); }