Beispiel #1
0
        public async Task <IActionResult> Index()
        {
            ApplicationUser currentUser = await _userManager.GetUserAsync(HttpContext.User);

            List <TodoItem> todoItems;
            TodoViewModel   todoView;
            IndexViewModel  model = new IndexViewModel();

            try
            {
                todoItems = _repository.GetActive(Guid.Parse(currentUser.Id));
                foreach (TodoItem i in todoItems)
                {
                    todoView = new TodoViewModel(i);
                    model.Items.Add(todoView);
                }
            }
            catch (ArgumentNullException ex)
            {
                _repository.AddError(ex.Message);
                return(View("Error"));
            }
            catch (FormatException ex)
            {
                _repository.AddError(ex.Message);
                return(View("Error"));
            }
            return(View(model));
        }