public ICommandResult Handle(StudentInputRegister command) { var course = new Course(command.CourseId); string password = string.Empty; string salt = string.Empty; if (!string.IsNullOrEmpty(command.CPF)) { password = _encryptor.Encrypt(command.CPF.Replace("-", "").Replace(".", ""), out salt); } var student = new Student(course, command.Birthdate, command.FirstName, command.LastName, command.CPF, command.Email, command.Phone, command.Gender, command.Country, command.City, command.Address, password, salt); var result = new StandardResult(); if (_SREP.Get(student.CPF.Number) != null) { result.Notifications.Add("CPF", "CPF já foi cadastrado!"); } result.AddRange(student.Notifications); if (result.Notifications.Count == 0) { _SREP.Create(student); result.Notifications.Add("Success", "O Acadêmico foi salvo"); } return(result); }
public ICommandResult Handle(ActivityInputUpdateGrade command) { var activity = new Activity(command.ActivityId, new Student(command.StudentId), command.Grade, command.Value); var result = new StandardResult(); result.AddRange(activity.Notifications); if (result.Notifications.Count == 0) { _AREP.Update(activity); result.Notifications.Add("Success", "A nota foi atualizada."); } return(result); }
public ICommandResult Handle(ActivityInputUpdate command) { decimal points = _AREP.GetByDiscipline(command.Activity.DisciplineId, new Semester()).Sum(x => x.Value); var activity = new Activity(new Discipline(command.Activity.DisciplineId), command.Activity.Description, command.Activity.Date, command.Activity.Value, points, command.Activity.MaxValue, command.Id); var result = new StandardResult(); result.AddRange(activity.Notifications); if (result.Notifications.Count == 0) { _AREP.Update(activity); result.Notifications.Add("Success", "A atividade foi atualizada."); } return(result); }
public ICommandResult Handle(DisciplineInputUpdate command) { int professorWorkload = _PREP.GetWorkload(command.ProfessorId); var discipline = new Discipline(command.Name, new Course(command.CourseId), new Professor(command.ProfessorId), command.WeeklyWorkload, command.Period, command.DisciplineId, professorWorkload); var result = new StandardResult(); result.AddRange(discipline.Notifications); if (result.Notifications.Count == 0) { _DREP.Update(discipline); result.Notifications.Add("Success", "O Acadêmico foi Editado"); } return(result); }
public ICommandResult Handle(ProfessorInputUpdate command) { var professor = new Professor(command.ProfessorId, command.FirstName, command.LastName, command.Email, command.Phone, command.Degree); var result = new StandardResult(); result.AddRange(professor.Notifications); if (result.Notifications.Count == 0) { _PREP.Update(professor); result.Notifications.Add("Success", "O Professor foi Editado"); } return(result); }
public ICommandResult Handle(StudentInputUpdate command) { var course = new Course(command.CourseId); var student = new Student(course, command.Birthdate, command.FirstName, command.LastName, command.Email, command.Phone, command.Gender, command.Country, command.City, command.Address, command.StudentId); var result = new StandardResult(); result.AddRange(student.Notifications); if (student.Notifications.Count == 0) { _SREP.Update(student); result.Notifications.Add("Success", "O Acadêmico foi Editado"); } return(result); }
public ICommandResult Handle(EnrollmentInputRegister command) { var semester = new Semester(); var enrollment = new Enrollment(new Student(command.StudentId), semester.Begin, semester.End, EStatusEnrollment.PreEnrollment); foreach (var discipline in command.Disciplines) { enrollment.AddDiscipline(new Discipline(discipline)); } var result = new StandardResult(); result.AddRange(enrollment.Notifications); if (result.Notifications.Count == 0) { _EREP.Create(enrollment); result.Notifications.Add("Success", "A Matrícula foi efetuada e está aguardando confirmação."); } return(result); }
public ICommandResult Handle(ProfessorInputRegister command) { string password = string.Empty; string salt = string.Empty; if (!string.IsNullOrEmpty(command.CPF)) { password = _encryptor.Encrypt(command.CPF.Replace("-", "").Replace(".", ""), out salt); } var professor = new Professor(command.FirstName, command.LastName, command.CPF, command.Email, command.Phone, command.Degree, password, salt); var result = new StandardResult(); result.AddRange(professor.Notifications); if (result.Notifications.Count == 0) { _PREP.Create(professor); result.Notifications.Add("Success", "O Professor foi salvo"); } return(result); }