public async Task <ActionResult <Task> > PostTask(Task task)
        {
            _context.Task.Add(task);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetTask", new { id = task.Id }, task));
        }
        public IActionResult CreateTask([Bind("ApplicationUsersId,ProjectinfoId", "Description", " DueDate", "Priority")] Task task)
        {
            if (ModelState.IsValid)
            {
                _taskRepo.Create(task);
                return(RedirectToAction("ProjectDetails", "Project", new { id = task.ProjectinfoId }));
            }

            return(RedirectToAction("CreateTask", new { projectid = task.ProjectinfoId }));
        }
        public async Task <IActionResult> PutTask(int id, Task task)
        {
            /*if (id != task.Id)
             * {
             *  return BadRequest();
             * }*/

            var editTask = await _context.Task.FindAsync(id);

            if (editTask == null)
            {
                return(BadRequest());
            }

            if (task.Assignee != null && editTask.Assignee != task.Assignee)
            {
                var tasks = _context.Task.Where(t => t.Assignee == task.Assignee);
                if (tasks.Count() == 3)
                {
                    return(BadRequest("Selected developer already have 3 tasks!"));
                }
            }

            editTask.Description = task.Description;
            editTask.Deadline    = task.Deadline;
            editTask.Assignee    = task.Assignee;
            editTask.ProjectId   = task.ProjectId;
            editTask.Status      = task.Status;
            editTask.Progress    = task.Progress;

            _context.Entry(editTask).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TaskExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }