public void ShouldReturnValidWhenEditCommandValid()
        {
            var command = new EditCollegeCommand();

            command.Id        = Guid.NewGuid();
            command.FirstName = "FirstName";
            command.LastName  = "LastName";
            command.Document  = "34.469.528/0001-26";
            command.Email     = "*****@*****.**";
            command.Phone     = "00000000000";
            command.Image     = "image.jpeg";
            var handler = new CollegeHandler(new CollegeRepositoryMock(), new EmailServiceMock());
            var result  = handler.Handle(command);

            Assert.AreEqual(true, result.Status);
        }
        public void ShouldReturnInvalidWhenEditCommandInvalid()
        {
            var command = new EditCollegeCommand();

            command.Id        = Guid.NewGuid();
            command.FirstName = "";
            command.LastName  = "";
            command.Document  = "";
            command.Email     = "example";
            command.Phone     = "";
            command.Image     = "";
            var handler = new CollegeHandler(new CollegeRepositoryMock(), new EmailServiceMock());
            var result  = handler.Handle(command);

            Assert.AreEqual(false, result.Status);
        }
Esempio n. 3
0
 public void Edit(EditCollegeCommand command)
 {
     _db.Connection().Execute(
         "spEditCollege",
         new
     {
         id        = command.Id,
         firstName = command.FirstName,
         lastName  = command.LastName,
         document  = command.Document,
         email     = command.Email,
         phone     = command.Phone,
         image     = command.Image
     },
         commandType: CommandType.StoredProcedure
         );
 }
        public ICommandResult Handle(EditCollegeCommand command)
        {
            var name     = new Name(command.FirstName, command.LastName);
            var email    = new Email(command.Email);
            var document = new Document(command.Document);

            AddNotifications(name.Notifications);
            AddNotifications(document.Notifications);
            AddNotifications(email.Notifications);

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

            _repository.Edit(command);
            _service.Send("*****@*****.**", email.Address, "Modificação", "Modificações realizadas com sucesso");
            return(new CommandResult(true, "Faculdade editada com sucesso", null));
        }
Esempio n. 5
0
 public ICommandResult Put([FromBody] EditCollegeCommand command)
 {
     return(_handler.Handle(command));
 }
Esempio n. 6
0
 public void Edit(EditCollegeCommand command)
 {
 }