예제 #1
0
 public IActionResult UpdateTask(ToDo td)
 {
     if (ModelState.IsValid)
     {
         _db.Update(td);
         _db.SaveChanges();
     }
     return(RedirectToAction("TaskList"));
 }
예제 #2
0
        public IActionResult UpdateTask(int Id)
        {
            Tasks found = _context.Tasks.Find(Id);

            if (ModelState.IsValid && found != null)
            {
                found.Complete = "Yes";

                _context.Entry(found).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                _context.Update(found);
                _context.SaveChanges();
            }
            return(RedirectToAction("ListTasks"));
        }
예제 #3
0
        public IActionResult CompleteTask(int id)
        {
            Tasks found = _context.Tasks.Find(id);

            if (found != null)
            {
                found.Complete = !found.Complete;

                _context.Entry(found).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                _context.Update(found);
                _context.SaveChanges();
            }
            return(RedirectToAction("TasksIndex"));
        }
예제 #4
0
        public IActionResult ToggleStatus(int id)
        {
            Tasks targetTask = _context.Tasks.Find(id);

            if (targetTask != null)
            {
                targetTask.Complete = !targetTask.Complete;
                _context.Entry(targetTask).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                _context.Update(targetTask);
                _context.SaveChanges();
            }

            return(RedirectToAction("TaskIndex"));
        }
예제 #5
0
        public IActionResult ChangeStatus(int id)
        {
            Tasks found = _context.Tasks.Find(id);

            if (found != null)
            {
                //Change the things!
                found.Complete = !found.Complete;
                //modify the state of this entry in the database
                _context.Entry(found).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                _context.Update(found);
                _context.SaveChanges();
            }
            return(RedirectToAction("Index"));
        }
        public IActionResult UpdateTask(Tasks newTask)
        {
            Tasks oldTask = _context.Tasks.Find(newTask.Id);

            if (ModelState.IsValid)
            {
                oldTask.Description           = newTask.Description;
                oldTask.DueDate               = newTask.DueDate;
                oldTask.Completion            = newTask.Completion;
                _context.Entry(oldTask).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                _context.Update(oldTask);
                _context.SaveChanges();
            }
            return(RedirectToAction("TaskIndex"));
        }
예제 #7
0
        public IActionResult Update(TaskList taskId)
        {
            TaskList found = _context.TaskList.Find(taskId.UserId);

            if (ModelState.IsValid && found != null)
            {
                found.Complete = "yes";

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

            return(RedirectToAction("TaskList"));
        }
예제 #8
0
        public IActionResult UpdateTask(int TaskId)
        {
            Tasks findTask = _taskContext.Tasks.Find(TaskId);

            if (findTask.Complete)
            {
                findTask.Complete = false;
            }
            else
            {
                findTask.Complete = true;
            }
            _taskContext.Entry(findTask).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            _taskContext.Update(findTask);
            _taskContext.SaveChanges();
            return(RedirectToAction("ListTasks"));
        }
        public IActionResult UpdateComplete(int id)
        {
            Tasks found = _context.Tasks.Find(id);

            if (found != null)
            {
                if (found.Completed == "false")
                {
                    found.Completed = "true";
                }
                else
                {
                    found.Completed = "false";
                }

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

            return(RedirectToAction("TaskIndex"));
        }
예제 #10
0
 public IActionResult EditTask(Tasks t)
 {
     _context.Update(t);
     _context.SaveChanges();
     return(RedirectToAction("TaskList"));
 }