Exemplo n.º 1
0
        public async Task <IActionResult> Add(AddLabelViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (!await _todoRepository.AddLabelAsync(new TodoItemLabel(model.Value)))
            {
                ModelState.AddModelError("Value", "Label is already added.");
                return(View(model));
            }

            return(RedirectToAction("Index"));
        }