Пример #1
0
        public async Task <IActionResult> Post(CreateProfessorCommand command)
        {
            try
            {
                await _professorApplicationService.Add(command);

                return(Ok(new { Message = "Professor Cadastrado com sucesso." }));
            }
            catch (ValidationException e)
            {
                return(BadRequest(ValidationAdapter.Parse(e.Errors)));
            }
            catch (Exception e)
            {
                return(StatusCode(500, e.Message));
            }
        }
Пример #2
0
 public void Create(CreateProfessorCommand Command)
 {
     _db.Connection().Execute(
         "spCreateProfessor",
         new
     {
         id        = Command.Id,
         firstName = Command.FirstName,
         lastName  = Command.LastName,
         document  = Command.Document,
         email     = Command.Email,
         phone     = Command.Phone,
         status    = Command.Status,
         idCourse  = Command.IdCourse
     },
         commandType: CommandType.StoredProcedure
         );
 }
Пример #3
0
        public ProfessorHandlerTests()
        {
            _validCreateCommand           = new CreateProfessorCommand();
            _validCreateCommand.FirstName = "FirstName";
            _validCreateCommand.LastName  = "LastName";
            _validCreateCommand.Document  = "402.020.980-44";
            _validCreateCommand.Email     = "*****@*****.**";
            _validCreateCommand.IdCourse  = Guid.NewGuid();
            _validCreateCommand.Phone     = "0000000000000";

            _invalidCreateCommand           = new CreateProfessorCommand();
            _invalidCreateCommand.FirstName = "";
            _invalidCreateCommand.LastName  = "";
            _invalidCreateCommand.Document  = "402.020.-44";
            _invalidCreateCommand.Email     = "example.com";
            _invalidCreateCommand.IdCourse  = Guid.NewGuid();
            _invalidCreateCommand.Phone     = "";

            _handler = new ProfessorHandler(new ProfessorRepositoryMock(), new EmailServiceMock());
        }
 public async Task Add(CreateProfessorCommand command)
 {
     await _mediator.Send(command);
 }
Пример #5
0
 public void Create(CreateProfessorCommand command)
 {
 }
 public ICommandResult Post([FromBody] CreateProfessorCommand command)
 {
     return(_handler.Handle(command));
 }