コード例 #1
0
        public IActionResult EditTasks(Tasks updateTask)
        {
            Tasks dbTasks = _context.Tasks.Find(updateTask.Id);

            if (ModelState.IsValid)
            {
                dbTasks.TaskDescription = updateTask.TaskDescription;
                dbTasks.DueDate         = updateTask.DueDate;
                dbTasks.Completed       = updateTask.Completed;

                _context.Entry(dbTasks).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                _context.Update(dbTasks);
                _context.SaveChanges();
            }
            return(RedirectToAction("Index"));
        }
コード例 #2
0
        public IActionResult EditTasks(Tasks tasks)
        {
            Tasks foundTasks = _context.Tasks.Find(tasks.Id);

            if (ModelState.IsValid)
            {
                foundTasks.TaskDescription = tasks.TaskDescription;
                foundTasks.DueDate         = tasks.DueDate;
                foundTasks.Completed       = tasks.Completed;

                _context.Entry(foundTasks).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                _context.Update(foundTasks);
                _context.SaveChanges();
            }


            return(RedirectToAction("Index"));
        }
コード例 #3
0
        public IActionResult EditTask(Tasks updatedTask)
        {
            // updatedTask.TaskOwnerId = User.FindFirst(ClaimTypes.NameIdentifier).Value;
            Tasks dbtask = _context.Tasks.Find(updatedTask.Id);

            if (ModelState.IsValid)
            {
                dbtask.TaskDescription = updatedTask.TaskDescription;
                dbtask.DueDate         = updatedTask.DueDate;
                dbtask.Completed       = updatedTask.Completed;

                //May need to delete
                _context.Entry(dbtask).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                _context.Update(dbtask);
                _context.SaveChanges();
            }
            return(RedirectToAction("Index"));
        }