Beispiel #1
0
        public void ShouldReturnValidWhenDeleteCommandIsValid()
        {
            var command = new DeleteProfessorCommand();

            command.Id = Guid.NewGuid();
            var handler = new ProfessorHandler(new ProfessorRepositoryMock(), new EmailServiceMock());
            var result  = handler.Handle(command);

            Assert.AreEqual(true, result.Status);
        }
Beispiel #2
0
 public void Delete(DeleteProfessorCommand command)
 {
     _db.Connection().Execute(
         "spDeleteProfessor",
         new
     {
         id = command.Id
     },
         commandType: CommandType.StoredProcedure
         );
 }
        public async Task <IActionResult> Delete(string id)
        {
            try
            {
                var command = new DeleteProfessorCommand {
                    Id = id
                };
                await _professorApplicationService.Remove(command);

                return(Ok(new { Message = "Professor Excluído com sucesso." }));
            }
            catch (Exception e)
            {
                return(StatusCode(500, e.Message));
            }
        }
Beispiel #4
0
        public ICommandResult Handle(DeleteProfessorCommand command)
        {
            string id = command.Id.ToString();

            if (string.IsNullOrEmpty(id))
            {
                AddNotification("Id", "Identificador inválido");
            }

            if (Invalid)
            {
                return(new CommandResult(false, "Erro ao deletar professor", Notifications));
            }

            _repository.Delete(command);
            return(new CommandResult(true, "Professor deletado com sucesso", null));
        }
        public async Task <Unit> Handle(DeleteProfessorCommand command, CancellationToken cancellationToken)
        {
            //var professor = new Professor
            //{
            //    Id = Guid.Parse(request.Id)
            //};
            var professor = _mapper.Map <Professor>(command);

            _professorDomainService.Remove(professor);

            await _mediator.Publish(new ProfessorNotification
            {
                Professor = professor,
                Action    = ActionNotification.Excluir
            });

            return(Unit.Value);
        }
 public async Task Remove(DeleteProfessorCommand command)
 {
     await _mediator.Send(command);
 }
Beispiel #7
0
 public void Delete(DeleteProfessorCommand command)
 {
 }
 public ICommandResult Delete(DeleteProfessorCommand command)
 {
     return(_handler.Handle(command));
 }