示例#1
0
        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());
        }
示例#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"));
        }
示例#9
0
        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"));
        }