public async Task <IActionResult> Adiciona([FromBody] Professor professor) { if (professor is null) { return(BadRequest()); } await _professorRepository.Create(professor); return(Ok()); }
public void Init() { _PREP = new ProfessorRepository(new MSSQLDB(new DBConfiguration())); _encryptor = new Encryptor(); string CPF = "034.034.034-00"; string password = _encryptor.Encrypt(CPF.Replace("-", "").Replace(".", ""), out string salt); professor = new Professor("Thelmaryo", "Vieira Lima", CPF, "*****@*****.**", "2134-4567", EDegree.Master, password, salt); _PREP.Create(professor); _UREP = new UserRepository(new MSSQLDB(new DBConfiguration())); password = _encryptor.Encrypt(CPF.Replace("-", "").Replace(".", ""), salt); _user = new User("*****@*****.**", password, salt, true); }
public ICommandResult Handle(CreateProfessorCommand command) { var name = new Name(command.FirstName, command.LastName); var document = new Document(command.Document); var email = new Email(command.Email); AddNotifications(name.Notifications); AddNotifications(document.Notifications); AddNotifications(email.Notifications); if (Invalid) { return(new CommandResult(false, "Erro ao cadastrar professor", Notifications)); } _repository.Create(command); _service.Send("*****@*****.**", email.Address, "Bem Vindo", "Seja bem vindo ao ClassRoom Space"); return(new CommandResult(true, "Professor cadastrado com sucesso", null)); }
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); }
public bool Insert(Professor prof) { _repository.Create(prof); return(_repository.SaveChanges()); }