public GradeTotalsViewModel(SchoolYearViewModel _schoolYear) { schoolYear = _schoolYear; Courses = new Dictionary <Guid, string>(); Students = new List <StudentViewModel>(); Dictionary <Guid, StudentViewModel> studentMap = new Dictionary <Guid, StudentViewModel>(); GradingPeriods = new List <GradingPeriodViewModel>(); foreach (GradingPeriodViewModel gradingPeriod in schoolYear.GradingPeriods) { GradingPeriods.Add(gradingPeriod); foreach (CourseViewModel course in gradingPeriod.Courses) { if (!Courses.ContainsKey(course.Id)) { Courses.Add(course.Id, course.Name); } } foreach (StudentViewModel student in gradingPeriod.Students) { if (!studentMap.ContainsKey(student.Id)) { studentMap.Add(student.Id, student); } } } Students = studentMap.Values.ToList(); }
public async Task <IActionResult> NewData(SchoolYearViewModel data) { if (Validate()) { var user = await CurrentUser(); if (!Validate(data, user)) { return(View()); } var result = await _sy.AddSchoolYear(data, user.School); if (result.Succeeded) { return(RedirectToAction("Success", new { message = "Creating new school year " + data.Name + " succeeded!" })); } else { AddPageAlerts(PageAlertType.Warning, result.Error.Description); } } return(View()); }
public async Task <IActionResult> EditData(SchoolYearViewModel data) { if (Validate()) { var user = await CurrentUser(); if (!Validate(data, user)) { return(View()); } var result = await _sy.UpdateSchoolYear(data, user.School); if (result.Succeeded) { return(RedirectToAction("Success", new { message = "Updating school year " + data.Name + " succeeded!" })); } else { AddPageAlerts(PageAlertType.Warning, result.Error.Description); } } AddPageHeader("School Years"); AddBreadcrumb("School Years", "/schoolyear"); AddBreadcrumb(data.Name, ""); return(View()); }
public GradeTotalsViewModel(SchoolYearViewModel _schoolYear) { schoolYear = _schoolYear; Courses = new Dictionary<Guid, string>(); Students = new List<StudentViewModel>(); Dictionary<Guid, StudentViewModel> studentMap = new Dictionary<Guid, StudentViewModel>(); GradingPeriods = new List<GradingPeriodViewModel>(); foreach (GradingPeriodViewModel gradingPeriod in schoolYear.GradingPeriods) { GradingPeriods.Add(gradingPeriod); foreach (CourseViewModel course in gradingPeriod.Courses) { if (!Courses.ContainsKey(course.Id)) { Courses.Add(course.Id, course.Name); } } foreach (StudentViewModel student in gradingPeriod.Students) { if (!studentMap.ContainsKey(student.Id)) { studentMap.Add(student.Id, student); } } } Students = studentMap.Values.ToList(); }
private bool Validate(SchoolYearViewModel data, SchoolUser user) { var IsValid = true; //check for overlapping dates from existing school years var sys = _sy.GetSchoolYears(user.School.Id); foreach (var sy in sys.Where(o => o.Id != data.Id)) { if (sy.Start.Value <= data.Start.Value && data.Start.Value <= sy.End.Value) { AddPageAlerts(PageAlertType.Warning, "Your date range is overlapping to " + sy.Name + "!"); IsValid = false; break; } else if (sy.Start.Value <= data.End.Value && data.End.Value <= sy.End.Value) { AddPageAlerts(PageAlertType.Warning, "Your date range is overlapping to " + sy.Name + "!"); IsValid = false; break; } if (sy.Name.ToLower().Trim() == data.Name.ToLower().Trim()) { AddPageAlerts(PageAlertType.Warning, "The name you use has already exist!"); IsValid = false; break; } } return(IsValid); }
public GradeTotalsForm(SchoolYearViewModel schoolYear) { InitializeComponent(); gradeTotalsVM = new GradeTotalsViewModel(schoolYear); addCourseTabs(); }
public SchoolYear(SchoolYearViewModel schoolYearVM) { this.Id = schoolYearVM.Id; this.Name = schoolYearVM.Name; this.isComplete = schoolYearVM.isComplete; this.GradingPeriods = new List <GradingPeriod>(); foreach (GradingPeriodViewModel gradingPeriodVM in schoolYearVM.GradingPeriods) { this.GradingPeriods.Add(new GradingPeriod(gradingPeriodVM)); } }
public async Task <ResponseResult <SchoolYearViewModel> > UpdateSchoolYear(SchoolYearViewModel data, SchoolProfile school) { await _manager.UpdateAsync(new Model.SchoolYear() { Id = data.Id, Name = data.Name, Start = data.Start.Value, End = data.End.Value, UpdatedDateTime = DateTime.Now }); return(ResponseResult <SchoolYearViewModel> .SetSuccess(data)); }
public async Task <ResponseResult <SchoolYearViewModel> > AddSchoolYear(SchoolYearViewModel data, SchoolProfile school) { await _manager.AddAsync(new Model.SchoolYear() { Name = data.Name, Start = data.Start.Value, End = data.End.Value, InsertedDateTime = DateTime.Now, UpdatedDateTime = DateTime.Now, School = school }); return(ResponseResult <SchoolYearViewModel> .SetSuccess(data)); }
public async Task <IActionResult> DeleteData(SchoolYearViewModel data) { var user = await CurrentUser(); var result = await _sy.DeleteSchoolYear(data); if (result.Succeeded) { return(RedirectToAction("Success", "SchoolYear", new { message = "Deleting school year " + data.Name + " succeeded!" })); } else { AddPageHeader("School Years"); AddBreadcrumb("School Years", "/schoolyear"); AddBreadcrumb(data.Name, ""); AddPageAlerts(PageAlertType.Warning, result.Error.Description); return(RedirectToAction("editdata", new { data.Id })); } }
public NewGradeWindow(SchoolYearViewModel schoolYearViewModel, MarkViewModel markViewModel) : base() { this.DataContext = new NewGradeWindowViewModel(schoolYearViewModel, markViewModel); InitializeComponent(); }