public TodoUpdateValidator(ITodoRepository repository)
        {
            _repository = repository;

            RuleFor(t => t).NotNull()
            .WithMessage(string.Format(Properties.Resource.ResourceManager.GetString("IsNullOrEmpty"), "Todo"));

            RuleFor(t => t.Description).NotEmpty()
            .WithMessage(string.Format(Properties.Resource.ResourceManager.GetString("IsNullOrEmpty"), nameof(TodoUpdateVm.Description)));

            RuleFor(t => t.Description).MinimumLength(MIN_DESCRIPTION_LENGTH)
            .WithMessage(string.Format(Properties.Resource.ResourceManager.GetString("MinLength"),
                                       nameof(TodoCreateVm.Description), MIN_DESCRIPTION_LENGTH));

            RuleFor(t => t.Description).MaximumLength(MAX_DESCRIPTION_LENGTH)
            .WithMessage(string.Format(Properties.Resource.ResourceManager.GetString("MaxLength"), nameof(TodoUpdateVm.Description), MAX_DESCRIPTION_LENGTH));

            RuleFor(t => t.Description).Must(t => _repository.All().All(todo => todo.Memento.Description != t))
            .WithMessage(string.Format(Properties.Resource.ResourceManager.GetString("NotUnique"), nameof(TodoUpdateVm.Description)));
        }
 public IActionResult Get()
 {
     return(Ok(_repository.All().Select(TodoDisplayVm.FromTodo).ToList()));
 }
Ejemplo n.º 3
0
 public IEnumerable <ToDoItem> All()
 {
     return(_todoRepository.All());
 }