public async Task <ActionResult <IEnumerable <TaskPom> > > GetTaskks(int userId) { List <Taskk> tasks = await _context.Tasks.ToListAsync(); List <Taskk> tasks1 = tasks.Where(t => t.UserId == userId).ToList(); List <TaskPom> taskspom = new List <TaskPom>(); foreach (Taskk t in tasks1) { TaskPom pom = new TaskPom(); pom.id = t.id; pom.end = t.endDate.ToString(); pom.start = t.startDate.ToString(); pom.note = t.note; pom.title = t.title; Status.Status status = await _context.Statuses.FindAsync(t.StatusId); pom.status = status.name; Priority.Priority priority = await _context.Priorities.FindAsync(t.PriorityId); pom.priority = priority.name; taskspom.Add(pom); } return(taskspom); }
public async Task <IActionResult> PutTaskPom(int id, TaskPom task) { Taskk pom = new Taskk(); pom.startDate = DateTime.Now; pom.endDate = DateTime.Now; pom.id = id; pom.note = task.note; pom.title = task.title; pom.UserId = task.UserId; Status.Status status = _context.Statuses.SingleOrDefault(x => x.name == task.status); pom.StatusId = status.id; Priority.Priority priority = _context.Priorities.SingleOrDefault(x => x.name == task.priority); pom.PriorityId = priority.id; return(await PutTaskk(id, pom)); }