public ActionResult Get(int id)
        {
            TasksUser task = db.TasksUsers.FirstOrDefault(x => x.Id == id);

            //User Put = db.Users.FirstOrDefault(x => x.Id == task.PutId);
            //User Respone = db.Users.FirstOrDefault(x => x.Id == task.ResponId);



            if (task != null)
            {
                var countComments = db.Comments.Count(s => s.TaskId == id);

                var res1 = db.TasksUsers.Join(db.Users,
                                              e => e.ResponId,
                                              o => o.Id,
                                              (e, o) => new
                {
                    Id         = e.Id,
                    ResponName = o.Family + " " + o.NameOth,
                    ResponId   = e.ResponId,
                    Text       = e.Text,
                    PutId      = e.PutId,
                    Main       = e.Main,
                    Status     = e.Status,
                    TimeStart  = e.TimeStart,
                    TimeEnd    = e.TimeEnd,
                    AllText    = e.AllText,
                    ImageURL   = e.URLimage
                                 //  Comments = e.Comments
                }
                                              );

                var res2 = res1.Join(db.Users,
                                     e => e.PutId,
                                     o => o.Id,
                                     (e, o) => new
                {
                    Id         = e.Id,
                    ResponName = e.ResponName,
                    ResponId   = e.ResponId,
                    Text       = e.Text,
                    PutName    = o.Family + " " + o.NameOth,
                    PutId      = e.PutId,
                    Main       = e.Main,
                    Status     = e.Status,
                    TimeStart  = e.TimeStart,
                    TimeEnd    = e.TimeEnd,
                    AllText    = e.AllText,
                    Comments   = countComments,
                    ImageURL   = e.ImageURL
                }
                                     );

                var result = res2.FirstOrDefault(x => x.Id == id);
                return(new ObjectResult(result));
            }

            return(NotFound());
        }
 public ActionResult Put(int id, [FromForm] TasksUser task)
 {
     if (db.TasksUsers.Any(x => x.Id == id))
     {
         db.Update(task);
         db.SaveChanges();
         return(Ok(task));
     }
     else
     {
         return(NotFound());
     }
 }
        public ActionResult Delete(int id)
        {
            var idClaim = User.Claims.FirstOrDefault(x => x.Type.Equals("Id", StringComparison.InvariantCultureIgnoreCase));

            if (idClaim != null)
            {
                TasksUser task = db.TasksUsers.FirstOrDefault(x => x.Id == id);

                if (task == null)
                {
                    return(NotFound());
                }

                if (task.PutId == int.Parse(idClaim.Value))
                {
                    db.TasksUsers.Remove(task);
                    db.SaveChanges();
                    return(Ok());
                }
                return(BadRequest("No"));
            }
            return(BadRequest());
        }