示例#1
0
        public async Task <ActionResult> Create(ToDoStatusViewModel item)
        {
            try
            {
                var todoItem = new ToDoItem()
                {
                    Title        = item.Title,
                    ToDoStatusId = item.ToDoStatusId
                };

                var user = await GetCurrentUserAsync();

                todoItem.ApplicationUserId = user.Id;

                _context.ToDoItem.Add(todoItem);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            catch (Exception ex)
            {
                return(View());
            }
        }
示例#2
0
 private void AddNewToDoItem(ToDoItem item)
 {
     item.DateCreated = DateTime.Now;
     _context.Add(item);
     _context.SaveChanges();
 }
示例#3
0
        public IActionResult Edit(int Id)
        {
            ToDoItem td = _db.ToDoItem.Find(Id);

            return(View(td));
        }
示例#4
0
 public IActionResult Delete(ToDoItem td)
 {
     _db.ToDoItem.Remove(td);
     _db.SaveChanges();
     return(RedirectToAction("ListTasks"));
 }