Exemplo n.º 1
0
        public IActionResult ChangePriority(int taskId, int priority, string direction, int selectedCategory)
        {
            Task taskToMove = _context.Tasks.First(t => t.TaskId == taskId);
            int priorityDirection = priority + ((direction == "up") ? -1 : 1);
            Task taskNext = _context.Tasks.First(t => t.Priority == priorityDirection);

            taskNext.Priority = priority;
            taskToMove.Priority = priorityDirection;

            _context.UpdateRange(taskToMove, taskNext);
            _context.SaveChanges();

            return RedirectToAction("GetList", new { categoryId = selectedCategory });
        }