Пример #1
0
        private void AddSemesterCommand(object parameter)
        {
            SemesterRegistration frm          = new SemesterRegistration(CurrentGrupa);
            Nullable <bool>      dialogResult = frm.ShowDialog();

            Semesters = Student.Semesters(_wybranaGrupa);
        }
Пример #2
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                TempData["Warning"] = "";
                return(RedirectToPage("/Admin/Children/Details", new { Id = ViewModel.ChildId }));
            }

            SemesterRegistration semesterRegistration = new SemesterRegistration()
            {
                ChildId    = ViewModel.ChildId,
                ClassScore = ViewModel.ClassScore,
                ExamScore  = ViewModel.ExamScore,
                SemesterId = ViewModel.SemesterId,
                SubjectId  = ViewModel.SubjectId
            };

            var response = await _childData.UpdateSemesterRegistationAsync(semesterRegistration);

            if (response)
            {
                TempData["Success"] = "Recored was updated successfully";
            }
            else
            {
                TempData["Failed"] = "Semester registration does not exist. Student has not been registered for the specified registration details";
            }


            return(RedirectToPage("/Admin/Children/Details", new { Id = ViewModel.ChildId }));
        }
Пример #3
0
        public async Task <bool> UpdateSemesterRegistationAsync(SemesterRegistration semesterRegistration)
        {
            var model = await _dataContext
                        .SemesterRegistrations
                        .SingleOrDefaultAsync(s =>
                                              s.ChildId == semesterRegistration.ChildId &&
                                              s.SemesterId == semesterRegistration.SemesterId &&
                                              s.SubjectId == semesterRegistration.SubjectId);

            if (model == null)
            {
                return(false);
            }

            model.ClassScore = semesterRegistration.ClassScore;
            model.ExamScore  = semesterRegistration.ExamScore;

            _dataContext.SemesterRegistrations.Update(model);
            await _dataContext.SaveChangesAsync();

            return(true);
        }