Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        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());
        }
Exemplo n.º 3
0
        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());
        }
Exemplo n.º 4
0
        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();
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        public GradeTotalsForm(SchoolYearViewModel schoolYear)
        {
            InitializeComponent();

            gradeTotalsVM = new GradeTotalsViewModel(schoolYear);

            addCourseTabs();
        }
Exemplo n.º 7
0
 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));
     }
 }
Exemplo n.º 8
0
        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));
        }
Exemplo n.º 9
0
        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));
        }
Exemplo n.º 10
0
        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 }));
            }
        }
Exemplo n.º 11
0
 public NewGradeWindow(SchoolYearViewModel schoolYearViewModel, MarkViewModel markViewModel) : base()
 {
     this.DataContext = new NewGradeWindowViewModel(schoolYearViewModel, markViewModel);
     InitializeComponent();
 }