public ICommandResult Handle(StudentCommand command)
 {
     try
     {
         return(CreateUser(_dbContext.Students, command).Result);
     }
     catch
     {
         return(CommandResult.Failed());
     }
 }
 public ICommandResult Handle(StudentCommand command)
 {
     try
     {
         return(EditUser(_dbContext.Students.Include(x => x.AppUser), command).Result);
     }
     catch
     {
         return(CommandResult.Failed());
     }
 }
Exemple #3
0
        public StudentResponseModel Create(StudentRequestModel request)
        {
            ValidationResult validationResult = validator.Validate(request);

            if (validationResult.HasErrors)
            {
                return(null);
            }

            StudentCommand command = new StudentCommand(request.FirstName, request.LastName, request.Email, request.DateOfBirth);
            Student        student = createStudentHandler.Handle(command);

            StudentResponseModel response = studentsMapper.Map(student);

            return(response);
        }
Exemple #4
0
        public MainViewModel()
        {
            SelectedEnrollment = _selectedEnrollment;

            try
            {
                _enrollmentCommand = new EnrollmentCommand(_connectionString);
                Enrollments.AddRange(_enrollmentCommand.GetList());

                StudentCommand studentCommand = new StudentCommand(_connectionString);
                Students.AddRange(studentCommand.GetList());

                CourseCommand courseCommand = new CourseCommand(_connectionString);
                Courses.AddRange(courseCommand.GetList());
            }
            catch (Exception ex)
            {
                UpdateAppStatus(ex.Message);
            }
        }
Exemple #5
0
        public MainViewModel()
        {
            SelectedEnrollment = new EnrollmentModel();

            try
            {   //Ezekbol a Modellekbol csinaljuk itt, a ViewModellben a View szamara hasznalhato property-ket
                _enrollmentCommand = new EnrollmentCommand(_connectionString);
                Enrollments.AddRange(_enrollmentCommand.GetList());

                StudentCommand studentCommand = new StudentCommand(_connectionString);
                Students.AddRange(studentCommand.GetList());

                CourseCommand courseCommand = new CourseCommand(_connectionString);
                Courses.AddRange(courseCommand.GetList());//Adds a list from the DB to our list
            }
            catch (Exception ex)
            {
                //AppStatus = ex.Message;
                //Mindig, ha megvaltozik az AppStatus, akkor az AppStatus property ertesuljon rola. Alert the UI. (Lasd MainView.xaml, StatusBar)
                UpdateAppStatus(ex.Message);
            }
        }