Exemplo n.º 1
0
        public IActionResult DeleteTask(int id)
        {
            Tasks found = _context.Task.Find(id);

            if (found != null)
            {
                _context.Task.Remove(found);
                _context.SaveChanges();
            }
            return(RedirectToAction("TasksIndex", new { id = found.Id }));
        }
Exemplo n.º 2
0
        public IActionResult AddTask(Tasks newTask)
        {
            newTask.AspNetUsersId = User.FindFirst(ClaimTypes.NameIdentifier).Value;

            if (ModelState.IsValid)
            {
                _context.Task.Add(newTask);
                _context.SaveChanges();
                return(RedirectToAction("TasksIndex"));
            }
            else
            {
                return(View());
            }
        }
Exemplo n.º 3
0
        public IActionResult MarkComplete(int id)
        {
            Tasks found = _context.Task.Find(id);

            if (found != null)
            {
                //change the things (we're changing the completed status)
                found.Completed = !found.Completed;

                //modify the state of this entry in the database
                _context.Entry(found).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                _context.Update(found);
                _context.SaveChanges();
            }
            return(RedirectToAction("TasksIndex", new { id = found.Id }));
        }