Ejemplo n.º 1
0
        public void ClearReminderDate(int taskID)
        {
            LoginUser     loginUser   = TSAuthentication.GetLoginUser();
            Reminder      reminder    = Reminders.GetReminderByTaskID(loginUser, taskID);
            StringBuilder description = new StringBuilder();

            description.Append("Changed Reminder Date to None.");
            reminder.Delete();
            reminder.Collection.Save();
            TaskLogs.AddTaskLog(loginUser, taskID, "Reminder deleted");

            SendModifiedNotification(loginUser.UserID, taskID);
        }
Ejemplo n.º 2
0
        public ReminderProxy SetReminderDueDate(int taskID, string data)
        {
            LoginUser     loginUser       = TSAuthentication.GetLoginUser();
            Reminder      reminder        = Reminders.GetReminderByTaskID(loginUser, taskID);
            StringBuilder description     = new StringBuilder();
            Task          task            = Tasks.GetTask(loginUser, taskID);
            TaskJsonInfo  info            = Newtonsoft.Json.JsonConvert.DeserializeObject <TaskJsonInfo>(data);
            DateTime      reminderDueDate = (DateTime)info.Reminder;

            if (reminder != null)
            {
                if (reminder.DueDate == null)
                {
                    description.Append(String.Format("Changed Reminder from \"{0}\" to \"{1}\".", "Unassigned", (reminderDueDate).ToString()));
                }
                else
                {
                    description.Append(String.Format("Changed Reminder from \"{0}\" to \"{1}\".", ((DateTime)reminder.DueDate).ToString(), (reminderDueDate).ToString()));
                }
                reminder.DueDate      = DataUtils.DateToUtc(loginUser, reminderDueDate);
                reminder.IsDismissed  = false;
                reminder.HasEmailSent = false;
                reminder.Collection.Save();
                TaskLogs.AddTaskLog(loginUser, taskID, description.ToString());
            }
            else
            {
                if (reminder == null)
                {
                    if (task.UserID == null)
                    {
                        reminder = CreateReminder(loginUser, taskID, task.Name, DataUtils.DateToUtc(loginUser, reminderDueDate), false);
                    }
                    else
                    {
                        reminder = CreateReminder(loginUser, taskID, task.Name, DataUtils.DateToUtc(loginUser, reminderDueDate), false, (int)task.UserID);
                    }
                    task.ReminderID = reminder.ReminderID;
                    task.Collection.Save();
                }
            }

            if (task.UserID != null && loginUser.UserID != task.UserID)
            {
                SendModifiedNotification(loginUser.UserID, task.TaskID);
            }

            return(reminder.GetProxy());
        }
Ejemplo n.º 3
0
        public int SetUser(int taskID, int value)
        {
            LoginUser loginUser = TSAuthentication.GetLoginUser();
            Task      task      = Tasks.GetTask(loginUser, taskID);

            Reminder reminder = Reminders.GetReminderByTaskID(loginUser, taskID);

            if (task.UserID != null && loginUser.UserID != task.UserID && value != task.UserID)
            {
                SendOldUserNotification(loginUser.UserID, (int)task.UserID, task.TaskID);
            }

            if (value != -1 && loginUser.UserID != value && value != task.UserID)
            {
                SendAssignedNotification(loginUser.UserID, task.TaskID);
            }

            //User is being set to unassigned
            if (value == -1)
            {
                if (reminder != null)
                {
                    reminder.Delete();
                    reminder.Collection.Save();
                    task.ReminderID = null;
                }
                task.UserID = null;
            }
            else
            {
                if (reminder != null)
                {
                    reminder.UserID = value;
                    reminder.Collection.Save();
                }
                task.UserID = value;
            }

            task.Collection.Save();

            User   u           = Users.GetUser(loginUser, value);
            string description = String.Format("{0} set task user to {1} ", TSAuthentication.GetUser(loginUser).FirstLastName, u == null ? "Unassigned" : u.FirstLastName);

            TaskLogs.AddTaskLog(loginUser, taskID, description);

            return(value);
        }