Ejemplo n.º 1
0
        public async Task <GenericCommandResult> Handle(UpdateCourseCommand command, CancellationToken cancellationToken)
        {
            command.Validate();
            if (command.Invalid)
            {
                return(new GenericCommandResult(false, "Ocorreu um erro", command.Notifications));
            }

            var course = _courseRepository.GetById(command.CourseId);

            course.UpdateName(command.Name);

            _courseRepository.Update(course);

            return(new GenericCommandResult(true, "Curso atualizado com sucesso", (DTOs.Course)course));
        }
Ejemplo n.º 2
0
        public ICommandResult Handle(UpdateCourseCommand command)
        {
            //Fail Fast Validation
            command.Validate();
            if (command.Invalid)
            {
                return(new GenericCommandResult(false, Messages.Ex_ExceptionGeneric, command.Notifications));
            }

            var course = _repository.GetById(command.Id);

            course.UpdateCourse(command.Title, command.Url, command.Value, command.Stars, command.RecomendedByEid);

            _repository.Update(course);

            return(new GenericCommandResult(true, Messages.Act_Update, course));
        }