public ICommandResult Handle(AddHealthCommand command)
        {
            command.Validate();

            if (command.Invalid)
            {
                AddNotifications(command);
                return(new CommandResult(false, "Erro ao adicionar", Notifications));
            }
            var student = _studentRepository.GetById(command.StudentID);
            var health  = new Health
                          (
                command.Height,
                command.Weight,
                command.BloodPressure,
                command.Allergies,
                command.Disabilities,
                command.Notes
                          );

            student.AddHealth(health);

            AddNotifications(student, health);

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

            _studentRepository.AddHealth(student.Id, health);

            return(new CommandResult(true, "Dados cadastrados com sucesso", Notifications));
        }
示例#2
0
 public ICommandResult AddHealth([FromBody] AddHealthCommand command)
 {
     return(_handler.Handle(command));
 }