public async Task <Student> Handle(UpdateStudentCommand command)
        {
            using (var dbContextScope = _dbContextScopeFactory.Create())
            {
                // Gets our context from our context scope
                var dbCtx = dbContextScope.DbContexts.GetByInterface <ISchoolDbContext>();

                var currentStudent = await dbCtx.Students.FindAsync(command.Id);

                if (!currentStudent.FirstMidName.Equals(command.FirstMidName) ||
                    !currentStudent.LastName.Equals(command.LastName))
                {
                    // Check if the new first and last names are already taken
                    if (await _studentNameExistsProcedure.HandleAsync <ISchoolDbContext>(command.FirstMidName, command.LastName))
                    {
                        throw new RecoverableException("Student FirstMid and LastName Already Exists");
                    }

                    currentStudent.FirstMidName = command.FirstMidName;
                    currentStudent.LastName     = command.LastName;

                    dbCtx.Entry(currentStudent).State = EntityState.Modified;

                    await dbContextScope.SaveChangesAsync();

                    // This student will have the Id field populated.
                    return(currentStudent);
                }

                throw new InvalidOperationException("User didn't change any editable fields. Only FirstMid or Last name can be changed");
            }
        }
 public async Task Handle(CreateStudentCommand request)
 {
     // Find if Student with same firstmid and last name already exists
     if (await _studentExistProcedure.HandleAsync <ISchoolDbContext>(request.FirstMidName, request.LastName))
     {
         throw new RecoverableException("A Student with that last and firstmid name already exists");
     }
 }