internal virtual async Task AddToDb(TQuery request, TEntity dbObj, CancellationToken cancellationToken) { if (request.Model.Id != 0) { return; } await dbContext.AddAsync(dbObj, cancellationToken); }
public async Task <IActionResult> Create(TodoListFields fields) { if (!ModelState.IsValid) { return(View(fields)); } var currentUser = await userStore.FindByIdAsync(User.Id(), CancellationToken.None); var todoList = new TodoList(currentUser, fields.Title); await dbContext.AddAsync(todoList); await dbContext.SaveChangesAsync(); return(RedirectToAction("Create", "TodoItem", new { todoList.TodoListId })); }