public async Task <IActionResult> PutTaskItem(long id, TaskItem taskItem) { if (id != taskItem.Id) { return(BadRequest()); } _context.Entry(taskItem).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TaskItemExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
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")); }
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")); }
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")); }
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")); }
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")); }
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 void Update(TEntity entity) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } var entry = _dbContext.Entry(entity); if (entry.State != EntityState.Modified) { if (entry.State == EntityState.Detached) { _dbSet.Attach(entity); entry.State = EntityState.Modified; } } }
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")); }