Example #1
0
        public async Task <IActionResult> AddItem(TodoItem item)
        {
            if (!ModelState.IsValid)
            {
                return(View("Index"));
            }

            var currentUser = await _userManager.GetUserAsync(User);

            if (currentUser == null)
            {
                return(Challenge());
            }

            var successful = await _toDoItemService.AddTodoItemsAsync(item, currentUser);

            if (!successful)
            {
                return(BadRequest("Could not return item"));
            }

            return(RedirectToAction("Index"));
        }