예제 #1
0
        public async Task <IActionResult> Edit(string id, [Bind("TaskTitle,TaskDetails")] Task task)
        {
            if (id != task.TaskTitle)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(task);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TaskExists(task.TaskTitle))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(task));
        }
예제 #2
0
        public async Task <IActionResult> Create([Bind("TaskTitle,TaskDetails")] Task task)
        {
            if (ModelState.IsValid)
            {
                _context.Add(task);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(task));
        }