public void deleteTasks(Tasks t)
 {
     using (PrioritizerUnitOfWork uow = UnitOfWork)
     {
         uow.Context.Tasks.DeleteObject(t);
         uow.Commit();
     }
 }
 public void deleteManagerTeamMemberRelations(ManagerTeamMemberRelations mtr)
 {
     using (PrioritizerUnitOfWork uow = UnitOfWork)
     {
         uow.Context.ManagerTeamMemberRelations.DeleteObject(mtr);
         uow.Commit();
     }
 }
 public void deleteAlert(Alerts a)
 {
     using (PrioritizerUnitOfWork uow = UnitOfWork)
     {
         uow.Context.Alerts.DeleteObject(a);
         uow.Commit();
     }
 }
 public void applyChangesMeetingAttendies(MeetingAttendies ma)
 {
     using (PrioritizerUnitOfWork uow = UnitOfWork)
     {
         uow.Context.MeetingAttendies.ApplyChanges(ma);
         uow.Commit();
     }
 }
 public void deleteUsers(Users u)
 {
     using (PrioritizerUnitOfWork uow = UnitOfWork)
     {
         uow.Context.Users.DeleteObject(u);
         uow.Commit();
     }
 }
 public void deleteAttachment(attachments a)
 {
     using (PrioritizerUnitOfWork uow = UnitOfWork)
     {
         uow.Context.attachments.DeleteObject(a);
         uow.Commit();
     }
 }
 public void deleteProjects(projects p)
 {
     using (PrioritizerUnitOfWork uow = UnitOfWork)
     {
         uow.Context.projects.DeleteObject(p);
         uow.Commit();
     }
 }
 public void applyChangesAttachments(attachments a)
 {
     using (PrioritizerUnitOfWork uow = UnitOfWork)
     {
         uow.Context.attachments.ApplyChanges(a);
         uow.Commit();
     }
 }
 public void applyChangesMeetingCategoryMap(MeetingCategoryMap mcm)
 {
     using (PrioritizerUnitOfWork uow = UnitOfWork)
     {
         uow.Context.MeetingCategoryMap.ApplyChanges(mcm);
         uow.Commit();
     }
 }
 public void deleteMeetingCategoryMap(MeetingCategoryMap mcm)
 {
     using (PrioritizerUnitOfWork uow = UnitOfWork)
     {
         uow.Context.MeetingCategoryMap.DeleteObject(mcm);
         uow.Commit();
     }
 }
 public void applyChangesMeetingTasks(MeetingTasks mt)
 {
     using (PrioritizerUnitOfWork uow = UnitOfWork)
     {
         uow.Context.MeetingTasks.ApplyChanges(mt);
         uow.Commit();
     }
 }
 public void deleteMeetingTasks(MeetingTasks mt)
 {
     using (PrioritizerUnitOfWork uow = UnitOfWork)
     {
         uow.Context.MeetingTasks.DeleteObject(mt);
         uow.Commit();
     }
 }
 public void applyChangesManagerTeamMemberRelations(ManagerTeamMemberRelations mtr)
 {
     using (PrioritizerUnitOfWork uow = UnitOfWork)
     {
         uow.Context.ManagerTeamMemberRelations.ApplyChanges(mtr);
         uow.Commit();
     }
 }
 public void applyChangesMeetingTasksList(List <MeetingTasks> changedMeetingTasksList)
 {
     using (PrioritizerUnitOfWork uow = UnitOfWork)
     {
         foreach (MeetingTasks mt in changedMeetingTasksList)
         {
             uow.Context.MeetingTasks.ApplyChanges(mt);
             uow.Commit();
         }
     }
 }
 public void applyChangesAlerts(Alerts a, Guid userID)
 {
     using (PrioritizerUnitOfWork uow = UnitOfWork)
     {
         if (a.ChangeTracker.State == ObjectState.Added)
         {
             uow.Context.Alerts.AddObject(a);
             Tasks task = uow.Context.Tasks.Where(t => t.ID == a.taskID).FirstOrDefault();
             task.StartTracking();
             task.hasAlert = true;
             applyChangesTasks(task, userID, uow);
             uow.Commit();
         }
         else if (a.ChangeTracker.ChangedProperties.Count > 0 || a.ChangeTracker.State != ObjectState.Modified)
         {
             uow.Context.Alerts.ApplyChanges(a);
             uow.Commit();
         }
     }
 }
        public void moveAllTasksPriorityForUserInternal(int numOfSteps, Guid userID, PrioritizerUnitOfWork uow, bool commitOnFinish)
        {
            if (uow == null)
            {
                uow = UnitOfWork;
            }

            uow.Context.ExecuteStoreCommand("update Tasks set priority=priority+{0} where userid={1}", numOfSteps, userID);
            if (commitOnFinish)
            {
                uow.Commit();
            }
        }
 public void applyChangesMeetings(Meetings m)
 {
     try
     {
         using (PrioritizerUnitOfWork uow = UnitOfWork)
         {
             if (m.ChangeTracker.State == ObjectState.Added)
             {
                 uow.Context.Meetings.AddObject(m);
                 uow.Commit();
             }
             else
             if (m.ChangeTracker.ChangedProperties.Count > 0 || m.ChangeTracker.State != ObjectState.Modified)
             {
                 uow.Context.Meetings.ApplyChanges(m);
                 uow.Commit();
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public void deleteMeetingAttendies(MeetingAttendies ma)
 {
     try
     {
         using (PrioritizerUnitOfWork uow = UnitOfWork)
         {
             var attendee = uow.Context.MeetingAttendies.Where(a => a.ID == ma.ID).FirstOrDefault();
             uow.Context.MeetingAttendies.DeleteObject(attendee);
             uow.Commit();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public void applyChangesProjects(projects p)
        {
            using (PrioritizerUnitOfWork uow = UnitOfWork)
            {
                bool projectAdded = false;
                if (p.ChangeTracker.State == ObjectState.Added)
                {
                    projectAdded = true;
                }
                uow.Context.projects.ApplyChanges(p);
                uow.Commit();

                if (projectAdded)
                {
                    loadProjectList();
                }
            }
        }
        public void applyChangesUsers(Users u)
        {
            using (PrioritizerUnitOfWork uow = UnitOfWork)
            {
                bool userAdded = false;
                if (u.ChangeTracker.State == ObjectState.Added)
                {
                    userAdded = true;
                }
                uow.Context.Users.ApplyChanges(u);
                uow.Commit();

                if (userAdded)
                {
                    loadUserssDictionary();
                }
            }
        }
        public void forwardTo(Guid taskID, Guid targetUserID, Guid loggedInUserID)
        {
            using (PrioritizerUnitOfWork uow = UnitOfWork)
            {
                Tasks t = uow.Context.Tasks.Where(a => a.ID == taskID).FirstOrDefault();
                t.StartTracking();

                //log action
                string loggedInUsername = UsersDict[loggedInUserID].userName;
                string log = string.Format("{0}{1}{2} - Forward to '{3}' by '{7}'{4}{5}{6}", LINE_DELIMITER, Environment.NewLine, DateTime.Now, UsersDict[(Guid)targetUserID].userName, Environment.NewLine, LINE_DELIMITER, Environment.NewLine, loggedInUsername);
                t.UpdatesLog = log + t.UpdatesLog;

                t.userID = targetUserID;
                logChanges(t, loggedInUserID);
                applyChangesTasks(t, loggedInUserID, uow);
                //t.AcceptChanges();
                uow.Commit();
            }
        }
        public void addAttachment(attachments a, Guid userID)
        {
            using (PrioritizerUnitOfWork uow = UnitOfWork)
            {
                try
                {
                    uow.Context.attachments.AddObject(a);

                    Tasks task = getTaskByID(a.taskID.Value);
                    task.StartTracking();
                    task.hasAttachment = true;
                    applyChangesTasks(task, userID, null);
                    uow.Commit();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
        internal Tasks applyChangesTasks(Tasks t, Guid userID, PrioritizerUnitOfWork uow)
        {
            try
            {
                if (uow == null)
                {
                    uow = UnitOfWork;
                }

                isolateTaskFromOtherTasksWithinSameMeeting(t);

                logChanges(t, userID);
                setUpdateDate(t, userID, uow);
                uow.Context.Tasks.ApplyChanges(t);


                uow.Commit();
                return(t);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public void copyTo(Guid taskID, Guid targetUserID, Guid loggedInUserID)
        {
            using (PrioritizerUnitOfWork uow = UnitOfWork)
            {
                Tasks t       = uow.Context.Tasks.Where(a => a.ID == taskID).FirstOrDefault();
                Tasks newTask = CloneTask(t, getMeetingTaskByID(taskID));

                newTask.StopTracking();
                newTask.dateUpdated = DateTime.Now;
                newTask.dateEntered = DateTime.Now;

                newTask.userID = targetUserID;
                newTask.ChangeTracker.State = ObjectState.Added;

                //log action
                string loggedInUserName = UsersDict[loggedInUserID].userName;
                string log = string.Format("{0}{1}{2} - Copied to '{3}' by '{7}' {4}{5}{6}", LINE_DELIMITER, Environment.NewLine, DateTime.Now, UsersDict[(Guid)newTask.userID].userName, Environment.NewLine, LINE_DELIMITER, Environment.NewLine, loggedInUserName);
                newTask.UpdatesLog = log + newTask.UpdatesLog;

                uow.Context.Tasks.AddObject(newTask);
                logChanges(newTask, loggedInUserID);
                uow.Commit();
            }
        }