public Task AddTask(HttpRequestMessage requestMessage, Task newTask)
 {
     return new Task
     {
         Subject = "In v2, newTask.Subject = " + newTask.Subject
     };
 }
 public virtual void UpdateTaskUsers(Task task, IEnumerable<long> userIds, bool appendToExisting)
 {
     if (!appendToExisting)
     {
         task.Users.Clear();
     }
     if (userIds != null)
     {
         foreach (var user in userIds.Select(GetValidUser))
         {
             if (!task.Users.Contains(user))
             {
                 task.Users.Add(user);
             }
         }
     }
 }
        public void AddTask(EA.WebApi.Data.Entities.Task task)
        {
            task.CreatedDate = _dateTime.UtcNow;
            task.Status      = _session.QueryOver <Status>().Where(x => x.Name == "Not Started").SingleOrDefault();
            // task.CreatedBy = _session.QueryOver<User>().Where(x => x.Username == _userSession.Username).SingleOrDefault();
            task.CreatedBy = _session.Get <User>(1L); // HACK: All tasks created by user 1 for now

            if (task.Users != null && task.Users.Any())
            {
                for (var i = 0; i < task.Users.Count; ++i)
                {
                    var user          = task.Users[i];
                    var persistedUser = _session.Get <User>(user.UserId);
                    if (persistedUser == null)
                    {
                        throw new ChildObjectNotFoundException("User not found");
                    }
                    task.Users[i] = persistedUser;
                }
            }
            _session.SaveOrUpdate(task);
        }
 public void UpdateTaskStatus(Task taskToUpdate, string statusName)
 {
     var status = _session.QueryOver<Status>().Where(x => x.Name == statusName).SingleOrDefault();
     taskToUpdate.Status = status;
     _session.SaveOrUpdate(taskToUpdate);
 }