public Users getUserByID(Guid userID)
 {
     using (PrioritizerUnitOfWork uow = UnitOfWork)
     {
         return(uow.Context.Users.Where(u => u.ID == userID).FirstOrDefault());
     }
 }
 private Guid handleTenantID(Guid?tenantID)
 {
     using (PrioritizerUnitOfWork uow = UnitOfWork)
     {
         if (tenantID == null)
         {
             if (DefaultTenantID == null)
             {
                 Tenant tenant = uow.Context.Tenant.Where(t => t.TenantName == "DefaultTenant").FirstOrDefault();
                 if (tenant != null)
                 {
                     DefaultTenantID = tenant.ID;
                 }
                 else
                 {
                     throw new Exception("Can't locate default tenant");
                 }
             }
             return(DefaultTenantID.Value);
         }
         else
         {
             return(tenantID.Value);
         }
     }
 }
 public IEnumerable <Meetings> getMeetingsForOwner(Guid ownerUserID)
 {
     using (PrioritizerUnitOfWork uow = UnitOfWork)
     {
         return(uow.Context.Meetings.Include("MeetingCategoryMap").Where(mc => mc.MeetingOwner == ownerUserID).ToList());
     }
 }
 public IEnumerable <MeetingAttendies> getMeetingAttendees(Guid meetingID)
 {
     using (PrioritizerUnitOfWork uow = UnitOfWork)
     {
         return(uow.Context.MeetingAttendies.Where(t => t.MeetingID == meetingID).ToList());
     }
 }
 public bool relationExists(Guid managerID, Guid teamMemberID)
 {
     using (PrioritizerUnitOfWork uow = UnitOfWork)
     {
         return(uow.Context.ManagerTeamMemberRelations.Where(t => t.ManagerID == managerID && t.TeamMemberID == teamMemberID).Count() > 0);
     }
 }
 public IEnumerable <TaskStatus> getTaskStatusList()
 {
     using (PrioritizerUnitOfWork uow = UnitOfWork)
     {
         return(uow.Context.TaskStatus.ToList());
     }
 }
 public IEnumerable <Tasks> getTasksByIDs(List <Guid> taskIDs)
 {
     using (PrioritizerUnitOfWork uow = UnitOfWork)
     {
         return(uow.Context.Tasks.Include("MeetingTasks").Include("MeetingTasks.Meetings").Where(t => taskIDs.Contains(t.ID)).ToList());
     }
 }
 public Meetings getMeetingByName(string meetingName)
 {
     using (PrioritizerUnitOfWork uow = UnitOfWork)
     {
         return(uow.Context.Meetings.Where(a => a.MeetingName == meetingName).First());
     }
 }
 public List <Alerts> getAlertForTask(Guid taskID)
 {
     using (PrioritizerUnitOfWork uow = UnitOfWork)
     {
         return(uow.Context.Alerts.Where(s => s.taskID == taskID).ToList());
     }
 }
 public MeetingTasks getMeetingTaskByID(Guid taskID)
 {
     using (PrioritizerUnitOfWork uow = UnitOfWork)
     {
         return(uow.Context.MeetingTasks.Where(a => a.TaskID == taskID).FirstOrDefault());
     }
 }
 public MeetingCategoryMap getMeetingCategoryMapByID(Guid meetingID)
 {
     using (PrioritizerUnitOfWork uow = UnitOfWork)
     {
         return(uow.Context.MeetingCategoryMap.Where(a => a.MeetingID == meetingID).FirstOrDefault());
     }
 }
 public Tasks getTaskByID(Guid taskID)
 {
     using (PrioritizerUnitOfWork uow = UnitOfWork)
     {
         return(uow.Context.Tasks.Where(task => task.ID == taskID).FirstOrDefault());
     }
 }
        public IEnumerable <Tasks> getTasksForUser(bool includeFinishedTasks, bool includeCancelledTasks, Guid userID)
        {
            try
            {
                using (PrioritizerUnitOfWork uow = UnitOfWork)
                {
                    if (includeFinishedTasks && includeCancelledTasks)//include all
                    {
                        return(uow.Context.Tasks.Include("MeetingTasks").Include("MeetingTasks.Meetings").Where(t => t.userID == userID).ToList());
                    }
                    else if (includeFinishedTasks && !includeCancelledTasks)//include only finished
                    {
                        return(uow.Context.Tasks.Include("MeetingTasks").Include("MeetingTasks.Meetings").Where(t => t.userID == userID && (t.taskStatusID <= 4 || t.taskStatusID == null)).ToList());
                    }
                    else if (!includeFinishedTasks && includeCancelledTasks)//include only cancelled
                    {
                        return(uow.Context.Tasks.Include("MeetingTasks").Include("MeetingTasks.Meetings").Where(t => t.userID == userID && (t.taskStatusID <= 3 || t.taskStatusID == 5 || t.taskStatusID == null)).ToList());
                    }
                    else if (!includeFinishedTasks && !includeCancelledTasks) //only pending/onhold/inprogress
                    {
                        return(uow.Context.Tasks.Include("MeetingTasks").Include("MeetingTasks.Meetings").Where(t => t.userID == userID && (t.taskStatusID <= 3 || t.taskStatusID == null)).ToList());
                    }

                    return(null);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public void moveAllTasksPriorityForUser(int numOfSteps, Guid userID)
 {
     using (PrioritizerUnitOfWork uow = UnitOfWork)
     {
         moveAllTasksPriorityForUserInternal(numOfSteps, userID, uow, true);
     }
 }
 public IEnumerable <Users> getMeetingAttendeesUserList(Guid meetingID)
 {
     using (PrioritizerUnitOfWork uow = UnitOfWork)
     {
         return(uow.Context.Users.Where(u => u.MeetingAttendies.Any(a => a.MeetingID == meetingID)).ToList());
     }
 }
 public void deleteMeetingCategoryMap(MeetingCategoryMap mcm)
 {
     using (PrioritizerUnitOfWork uow = UnitOfWork)
     {
         uow.Context.MeetingCategoryMap.DeleteObject(mcm);
         uow.Commit();
     }
 }
 public void deleteManagerTeamMemberRelations(ManagerTeamMemberRelations mtr)
 {
     using (PrioritizerUnitOfWork uow = UnitOfWork)
     {
         uow.Context.ManagerTeamMemberRelations.DeleteObject(mtr);
         uow.Commit();
     }
 }
 public IEnumerable <ManagerTeamMemberRelations> getManagerTeamMemberRelationsList(Guid?tenantID)
 {
     using (PrioritizerUnitOfWork uow = UnitOfWork)
     {
         tenantID = handleTenantID(tenantID);
         return(uow.Context.ManagerTeamMemberRelations.Include("Tenant").Where(u => u.TenantID == tenantID.Value).ToList());
     }
 }
 public void applyChangesAttachments(attachments a)
 {
     using (PrioritizerUnitOfWork uow = UnitOfWork)
     {
         uow.Context.attachments.ApplyChanges(a);
         uow.Commit();
     }
 }
 public void deleteAttachment(attachments a)
 {
     using (PrioritizerUnitOfWork uow = UnitOfWork)
     {
         uow.Context.attachments.DeleteObject(a);
         uow.Commit();
     }
 }
 public void applyChangesMeetingAttendies(MeetingAttendies ma)
 {
     using (PrioritizerUnitOfWork uow = UnitOfWork)
     {
         uow.Context.MeetingAttendies.ApplyChanges(ma);
         uow.Commit();
     }
 }
 public void applyChangesManagerTeamMemberRelations(ManagerTeamMemberRelations mtr)
 {
     using (PrioritizerUnitOfWork uow = UnitOfWork)
     {
         uow.Context.ManagerTeamMemberRelations.ApplyChanges(mtr);
         uow.Commit();
     }
 }
 public void deleteProjects(projects p)
 {
     using (PrioritizerUnitOfWork uow = UnitOfWork)
     {
         uow.Context.projects.DeleteObject(p);
         uow.Commit();
     }
 }
 public void deleteUsers(Users u)
 {
     using (PrioritizerUnitOfWork uow = UnitOfWork)
     {
         uow.Context.Users.DeleteObject(u);
         uow.Commit();
     }
 }
 public List <Alerts> getAlertsForUser(Guid userID)
 {
     using (PrioritizerUnitOfWork uow = UnitOfWork)
     {
         var alertList = uow.Context.Alerts.Include("Tasks").Where(a => a.Tasks.userID == userID && a.active.Value && a.Tasks.taskStatusID <= 3).ToList();
         return(alertList);
     }
 }
 public void applyChangesMeetingCategoryMap(MeetingCategoryMap mcm)
 {
     using (PrioritizerUnitOfWork uow = UnitOfWork)
     {
         uow.Context.MeetingCategoryMap.ApplyChanges(mcm);
         uow.Commit();
     }
 }
 public void deleteMeetingTasks(MeetingTasks mt)
 {
     using (PrioritizerUnitOfWork uow = UnitOfWork)
     {
         uow.Context.MeetingTasks.DeleteObject(mt);
         uow.Commit();
     }
 }
 public IEnumerable <Users> getUserByDomainName(string domainName, Guid?tenantID)
 {
     using (PrioritizerUnitOfWork uow = UnitOfWork)
     {
         tenantID = handleTenantID(tenantID);
         return(uow.Context.Users.Include("Tenant").Where(u => u.domainUserName == domainName && u.TenantID == tenantID.Value).ToList());
     }
 }
 public void deleteAlert(Alerts a)
 {
     using (PrioritizerUnitOfWork uow = UnitOfWork)
     {
         uow.Context.Alerts.DeleteObject(a);
         uow.Commit();
     }
 }
 public void applyChangesMeetingTasks(MeetingTasks mt)
 {
     using (PrioritizerUnitOfWork uow = UnitOfWork)
     {
         uow.Context.MeetingTasks.ApplyChanges(mt);
         uow.Commit();
     }
 }