public int GetLatestWatercoolerCount()
        {
            User            user = TSAuthentication.GetUser(TSAuthentication.GetLoginUser());
            WaterCoolerView wcv  = new WaterCoolerView(TSAuthentication.GetLoginUser());

            return(wcv.GetLatestWatercoolerCount(user.LastLoginUtc.ToString()));
        }
    public static void SendSlackMsg(string message)
    {
        User user = TSAuthentication.GetUser(TSAuthentication.GetLoginUser());

        //SendMessageToSlack(user.FirstLastName + " has acknowledged this issue on pod " + SystemSettings.GetPodName());
        SendMessageToSlack(string.Format("[{0}] {1} {2}", SystemSettings.GetPodName(), user.FirstLastName, message));
    }
        public UserProxy GetCurrentUser()
        {
            UserProxy user = TSAuthentication.GetUser(TSAuthentication.GetLoginUser()).GetProxy();

            user.CryptedPassword = string.Empty;
            return(user);
        }
        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);
        }
        public TaskCompletionStatus SetTaskIsCompleted(int taskID, bool value)
        {
            TaskCompletionStatus result = new TaskCompletionStatus(false, value);

            LoginUser loginUser = TSAuthentication.GetLoginUser();
            Task      task      = Tasks.GetTask(loginUser, taskID);

            task.IsComplete = value;

            //if a user is attempting to complete a task check for incomplete subtasks first
            if (value)
            {
                if (GetIncompleteSubtasks(taskID))
                {
                    result.IncompleteSubtasks = true;
                    result.Value = !value;
                    return(result);
                }
                task.DateCompleted   = DateTime.UtcNow;
                result.DateCompleted = task.DateCompleted;
            }
            else
            {
                result.IncompleteSubtasks = false;
                result.Value       = value;
                task.DateCompleted = null;
            }

            //We are clearing completion comments as they could or not be set in next call.
            task.CompletionComment = null;
            task.Collection.Save();
            string description = String.Format("{0} set task is complete to {1} ", TSAuthentication.GetUser(loginUser).FirstLastName, value);

            TaskLogs.AddTaskLog(loginUser, taskID, description);

            if (task.IsComplete && (loginUser.UserID != task.CreatorID || (task.UserID != null && loginUser.UserID != task.UserID)))
            {
                SendCompletedNotification(loginUser.UserID, task.TaskID);
            }
            else if (task.UserID != null && loginUser.UserID != task.UserID)
            {
                SendModifiedNotification(loginUser.UserID, task.TaskID);
            }

            return(result);
        }
        public string SetDescription(int taskID, string value)
        {
            LoginUser loginUser = TSAuthentication.GetLoginUser();
            Task      task      = Tasks.GetTask(loginUser, taskID);

            task.Description = value;
            task.Collection.Save();
            string description = String.Format("{0} set task description to {1} ", TSAuthentication.GetUser(loginUser).FirstLastName, value);

            TaskLogs.AddTaskLog(loginUser, taskID, description);

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

            return(value != "" ? value : "Empty");
        }
        public TaskCompletionStatus AddTaskCompleteComment(int taskID, string comment)
        {
            LoginUser loginUser = TSAuthentication.GetLoginUser();
            Task      task      = Tasks.GetTask(loginUser, taskID);

            task.CompletionComment = comment;
            task.Collection.Save();

            //string description = String.Format(@"{0} added task complete note: ""{1}""", TSAuthentication.GetUser(loginUser).FirstLastName, comment);
            string description = String.Format(@"{0} added task complete note.", TSAuthentication.GetUser(loginUser).FirstLastName);

            TaskLogs.AddTaskLog(loginUser, taskID, description);

            TaskCompletionStatus result = new TaskCompletionStatus(false, true);

            result.DateCompleted     = task.DateCompleted;
            result.CompletionComment = task.CompletionComment;
            return(result);
        }
Beispiel #8
0
        public void DeleteOrganizationProduct(int organizationProductID, bool bypass = true)
        {
            if (!UserSession.CurrentUser.IsSystemAdmin && bypass)
            {
                return;
            }
            try
            {
                OrganizationProducts organizationProducts = new OrganizationProducts(UserSession.LoginUser);
                organizationProducts.LoadByOrganizationProductID(organizationProductID);
                UserProducts userProducts = new UserProducts(UserSession.LoginUser);
                //userProducts.LoadByOrganizationProductAndVersionID(organizationProducts[0].OrganizationID, "hola", "adios");
                userProducts.LoadByOrganizationProductAndVersionID(organizationProducts[0].OrganizationID, organizationProducts[0].ProductID, organizationProducts[0].ProductVersionID);
                userProducts.DeleteAll();
                userProducts.Save();
                organizationProducts.DeleteFromDB(organizationProductID);

                Product p           = Products.GetProduct(TSAuthentication.GetLoginUser(), organizationProducts[0].ProductID);
                string  description = String.Format("{0} deleted product association to {1} ", TSAuthentication.GetUser(TSAuthentication.GetLoginUser()).FirstLastName, p.Name);
                ActionLogs.AddActionLog(TSAuthentication.GetLoginUser(), ActionLogType.Delete, ReferenceType.Organizations, organizationProducts[0].OrganizationID, description);
            }
            catch (Exception ex)
            {
                DataUtils.LogException(UserSession.LoginUser, ex);
            }
        }
        public TsMenuItem[] GetMainMenuItems()
        {
            List <TsMenuItem> items     = new List <TsMenuItem>();
            LoginUser         loginUser = TSAuthentication.GetLoginUser();

            Organization org  = TSAuthentication.GetOrganization(loginUser);
            User         user = TSAuthentication.GetUser(loginUser);
            string       data = @"{{""ContentUrl"":""{0}"",""PaneInfoUrl"":""{1}""}}";


            if (org.ParentID != null)
            {
                if (user.ShowWelcomePage == true && user.IsSystemAdmin == true)
                {
                    items.Add(new TsMenuItem("welcome", "mniWelcome", "Getting Started", "vcr/1_9_0/images/nav/20/GettingStarted.png", string.Format(data, "vcr/1_9_0/Pages/Welcome.html", "vcr/1_9_0/PaneInfo/Welcome.html")));
                }

                if (IsMenuItemActive(user, "mniDashboard"))
                {
                    items.Add(new TsMenuItem("dashboard", "mniDashboard", "Dashboard", "vcr/1_9_0/images/nav/20/Dashboard.png", string.Format(data, "vcr/1_9_0/Pages/Dashboard.html", "vcr/1_9_0/PaneInfo/Dashboard.html")));
                }

                if (IsMenuItemActive(user, "mniMyTickets"))
                {
                    TsMenuItem myItem = new TsMenuItem("mytickets", "mniMyTickets", "My Tickets", "vcr/1_9_0/images/nav/20/mytickets.png", string.Format(data, "vcr/1_9_0/Pages/TicketTabs.html?UserID=" + TSAuthentication.UserID, "vcr/1_9_0/PaneInfo/MyTickets.html"));
                    items.Add(myItem);

                    Reports privateTicketViews = new Reports(TSAuthentication.GetLoginUser());
                    privateTicketViews.LoadAllPrivateTicketViews(TSAuthentication.OrganizationID, TSAuthentication.UserID);

                    if (!privateTicketViews.IsEmpty)
                    {
                        foreach (Report report in privateTicketViews)
                        {
                            myItem.AddItem(new TsMenuItem("tickettype", "mniTicketView_" + report.ReportID.ToString(), report.Name, "vcr/1_9_0/images/nav/20/tickets.png", string.Format(data, "vcr/1_9_0/Pages/TicketView.html?ReportID=" + report.ReportID.ToString(), "vcr/1_9_0/PaneInfo/Reports.html")));
                        }
                    }
                }

                if (IsMenuItemActive(user, "mniTickets"))
                {
                    TsMenuItem ticketItem = new TsMenuItem("tickets", "mniTickets", "All Tickets", "vcr/1_9_0/images/nav/20/tickets.png", string.Format(data, "vcr/1_9_0/Pages/TicketTabs.html", "vcr/1_9_0/PaneInfo/Tickets.html"));
                    items.Add(ticketItem);

                    Reports publicTicketViews = new Reports(TSAuthentication.GetLoginUser());
                    publicTicketViews.LoadAllPublicTicketViews(TSAuthentication.OrganizationID, TSAuthentication.UserID);

                    if (!publicTicketViews.IsEmpty)
                    {
                        foreach (Report report in publicTicketViews)
                        {
                            ticketItem.AddItem(new TsMenuItem("tickettype", "mniTicketView_" + report.ReportID.ToString(), report.Name, "vcr/1_9_0/images/nav/20/tickets.png", string.Format(data, "vcr/1_9_0/Pages/TicketView.html?ReportID=" + report.ReportID.ToString(), "vcr/1_9_0/PaneInfo/Reports.html")));
                        }
                    }

                    TicketTypes ticketTypes = new TicketTypes(loginUser);
                    ticketTypes.LoadByOrganizationID(TSAuthentication.OrganizationID, org.ProductType);
                    foreach (TicketType ticketType in ticketTypes)
                    {
                        if (ticketType.IsActive)
                        {
                            string mniID = "mniTicketType_" + ticketType.TicketTypeID.ToString();
                            if (IsMenuItemActive(user, mniID))
                            {
                                ticketItem.AddItem(new TsMenuItem("tickettype", mniID, ticketType.Name, ticketType.IconUrl, string.Format(data, "vcr/1_9_0/Pages/TicketTabs.html?TicketTypeID=" + ticketType.TicketTypeID.ToString(), "vcr/1_9_0/PaneInfo/Tickets.html")));
                            }
                        }
                    }
                }

                if (org.ProductType == ProductType.Enterprise && IsMenuItemActive(user, "mniTasks"))
                {
                    items.Add(new TsMenuItem("tasks", "mniTasks", "Tasks", "vcr/1_9_0/images/nav/20/tasks.png", string.Format(data, "vcr/1_9_0/Pages/tasks.html", "vcr/1_9_0/PaneInfo/Tasks.html")));
                }

                if (IsMenuItemActive(user, "mniTicketTags"))
                {
                    items.Add(new TsMenuItem("tickettags", "mniTicketTags", "Ticket Tags", "vcr/1_9_0/images/nav/20/tag.png", string.Format(data, "Frames/TicketTags.aspx", "vcr/1_9_0/PaneInfo/TicketTags.html")));
                }

                if (IsMenuItemActive(user, "mniKB"))
                {
                    items.Add(new TsMenuItem("kb", "mniKB", "Knowledge Base", "vcr/1_9_0/images/nav/20/knowledge.png", string.Format(data, "vcr/1_9_0/Pages/KnowledgeBase.html", "vcr/1_9_0/PaneInfo/Knowledge.html")));
                }

                if (IsMenuItemActive(user, "mniForum") && org.UseForums == true)
                {
                    items.Add(new TsMenuItem("forum", "mniForum", "Community", "vcr/1_9_0/images/nav/20/forum.png", string.Format(data, "vcr/1_9_0/Pages/TicketGrid.html?tf_ForumCategoryID=-1", "vcr/1_9_0/PaneInfo/Community.html")));
                }

                if (org.ProductType != ProductType.Express && IsMenuItemActive(user, "mniWiki"))
                {
                    items.Add(new TsMenuItem("wiki", "mniWiki", "Wiki", "vcr/1_9_0/images/nav/20/wiki.png", string.Format(data, "vcr/1_9_0/Pages/Wiki_view.html", "vcr/1_9_0/PaneInfo/Wiki_view.html")));
                }

                if (IsMenuItemActive(user, "mniSearch"))
                {
                    items.Add(new TsMenuItem("search", "mniSearch", "Search", "vcr/1_9_0/images/nav/20/search.png", string.Format(data, "vcr/1_9_0/Pages/Search.html", "vcr/1_9_0/PaneInfo/Search.html")));
                }

                if (user.IsChatUser && org.ChatSeats > 0 && IsMenuItemActive(user, "mniChat"))
                {
                    //old chat: items.Add(new TsMenuItem("chat", "mniChat", "Customer Chat", "vcr/1_9_0/images/nav/20/chat.png", string.Format(data, "Frames/Chat.aspx", "vcr/1_9_0/PaneInfo/Chat.html")));
                    items.Add(new TsMenuItem("chat", "mniChat", "Customer Chat", "vcr/1_9_0/images/nav/20/chat.png", string.Format(data, "vcr/1_9_0/Pages/AgentCustomerChat.html", "vcr/1_9_0/PaneInfo/Chat.html")));
                }

                if (org.ProductType != ProductType.Express && IsMenuItemActive(user, "mniWC2"))
                {
                    items.Add(new TsMenuItem("wc2", "mniWC2", "Water Cooler", "vcr/1_9_0/images/nav/20/watercooler.png", string.Format(data, "vcr/1_9_0/Pages/WaterCooler.html", "vcr/1_9_0/PaneInfo/WaterCooler.html")));
                }

                items.Add(new TsMenuItem("calender", "mniCalender", "Calendar", "vcr/1_9_0/images/nav/20/calendar.png", string.Format(data, "vcr/1_9_0/Pages/Calendar.html", "vcr/1_9_0/PaneInfo/Calendar.html")));

                if (IsMenuItemActive(user, "mniUsers"))
                {
                    items.Add(new TsMenuItem("users", "mniUsers", "Users", "vcr/1_9_0/images/nav/20/users.png", string.Format(data, "vcr/1_9_0/Pages/Users.html", "vcr/1_9_0/PaneInfo/Users.html")));
                }

                if (IsMenuItemActive(user, "mniGroups"))
                {
                    items.Add(new TsMenuItem("groups", "mniGroups", "Groups", "vcr/1_9_0/images/nav/20/groups.png", string.Format(data, "vcr/1_9_0/Pages/Groups.html", "vcr/1_9_0/PaneInfo/Groups.html")));
                    //items.Add(new TsMenuItem("groups1", "mniGroups1", "Groups1", "vcr/1_9_0/images/nav/20/groups.png", string.Format(data, "Frames/Groups.aspx", "vcr/1_9_0/PaneInfo/Groups.html")));
                }

                if ((org.ProductType == ProductType.Enterprise || org.ProductType == ProductType.HelpDesk) && IsMenuItemActive(user, "mniCustomers"))
                {
                    //items.Add(new TsMenuItem("customers1", "mniCustomers1", "Customers1", "vcr/1_9_0/images/nav/20/customers.png", string.Format(data, "Frames/Organizations.aspx", "vcr/1_9_0/PaneInfo/Customers.html")));
                    items.Add(new TsMenuItem("customers", "mniCustomers", "Customers", "vcr/1_9_0/images/nav/20/customers.png", string.Format(data, "vcr/1_9_0/Pages/Customers.html", "vcr/1_9_0/PaneInfo/Customers.html")));
                }


                if ((org.ProductType == ProductType.Enterprise || org.ProductType == ProductType.BugTracking) && IsMenuItemActive(user, "mniProducts"))
                {
                    items.Add(new TsMenuItem("products", "mniProducts", "Products", "vcr/1_9_0/images/nav/20/products.png", string.Format(data, "vcr/1_9_0/Pages/Products.html", "vcr/1_9_0/PaneInfo/Products.html")));
                    //items.Add(new TsMenuItem("products", "mniProducts", "Products", "vcr/1_9_0/images/nav/20/products.png", string.Format(data, "Frames/Products.aspx", "vcr/1_9_0/PaneInfo/Products.html")));
                    //if (TSAuthentication.OrganizationID == 1078 || TSAuthentication.OrganizationID == 13679 || TSAuthentication.OrganizationID == 362372 || TSAuthentication.OrganizationID == 428340)
                    //{
                    //  items.Add(new TsMenuItem("products", "mniProducts1", "New Products", "vcr/1_9_0/images/nav/20/products.png", string.Format(data, "vcr/1_9_0/Pages/Products.html", "vcr/1_9_0/PaneInfo/Products.html")));
                    //}
                }

                if (org.IsInventoryEnabled && IsMenuItemActive(user, "mniInventory"))
                {
                    //items.Add(new TsMenuItem("inventory", "mniInventory", "Inventory", "vcr/1_9_0/images/nav/20/inventory.png", string.Format(data, "Inventory/Inventory.aspx", "vcr/1_9_0/PaneInfo/Inventory.html")));
                    items.Add(new TsMenuItem("inventory", "mniInventory", "Inventory", "vcr/1_9_0/images/nav/20/inventory.png", string.Format(data, "vcr/1_9_0/Pages/Inventory.html", "vcr/1_9_0/PaneInfo/Inventory.html")));
                }

                if ((user.IsSystemAdmin || !org.AdminOnlyReports) && IsMenuItemActive(user, "mniReports"))
                {
                    items.Add(new TsMenuItem("reports", "mniReports", "Reports", "vcr/1_9_0/images/nav/20/reports.png", string.Format(data, "vcr/1_9_0/pages/reports.html", "vcr/1_9_0/PaneInfo/Reports.html")));
                }

                if (user.IsSystemAdmin && IsMenuItemActive(user, "mniAdmin"))
                {
                    items.Add(new TsMenuItem("admin", "mniAdmin", "Admin", "vcr/1_9_0/images/nav/20/admin.png", string.Format(data, "Frames/Admin.aspx", "vcr/1_9_0/PaneInfo/Admin.html")));
                }

                if (TSAuthentication.OrganizationID == 1078)
                {
                    TsMenuItem utils = new TsMenuItem("utils", "mniUtils", "Utilities", "vcr/1_9_0/images/nav/20/admin.png", string.Format(data, "vcr/1_9_0/Utils/Utils.html", "vcr/1_9_0/PaneInfo/Admin.html"));
                    items.Add(utils);
                    utils.AddItem(new TsMenuItem("utils", "utils-accounts", "Accounts", "vcr/1_9_0/images/nav/20/admin.png", string.Format(data, "vcr/1_9_0/Utils/Accounts.html", "vcr/1_9_0/PaneInfo/Admin.html")));
                    utils.AddItem(new TsMenuItem("utils", "utils-tickets", "Tickets", "vcr/1_9_0/images/nav/20/admin.png", string.Format(data, "vcr/1_9_0/Utils/Tickets.html", "vcr/1_9_0/PaneInfo/Admin.html")));
                    utils.AddItem(new TsMenuItem("utils", "utils-organizations", "Organizations", "vcr/1_9_0/images/nav/20/admin.png", string.Format(data, "vcr/1_9_0/Utils/Organizations.html", "vcr/1_9_0/PaneInfo/Admin.html")));
                    utils.AddItem(new TsMenuItem("utils", "utils-devflow", "Dev Workflow", "vcr/1_9_0/images/nav/20/admin.png", string.Format(data, "https://app.teamsupport.com/wiki/justarticle.aspx?Organizationid=1078&ArticleID=44728", "vcr/1_9_0/PaneInfo/Admin.html")));
                    if (user.UserID == 34 || user.UserID == 47 || user.UserID == 4759191)
                    {
                        utils.AddItem(new TsMenuItem("utils", "utils-reporttest", "Custom Reports", "vcr/1_9_0/images/nav/20/admin.png", string.Format(data, "vcr/1_9_0/Utils/ReportTest.html", "vcr/1_9_0/PaneInfo/Admin.html")));
                    }
                }
            }
            else
            {
                items.Add(new TsMenuItem("tsusers", "mniUsers", "System Users", "vcr/1_9_0/images/nav/20/users.png", string.Format(data, "Frames/Users.aspx", "vcr/1_9_0/PaneInfo/Users.html")));
                items.Add(new TsMenuItem("tscustomers", "mniCustomers", "System Customers", "vcr/1_9_0/images/nav/20/customers.png", string.Format(data, "Frames/Organizations.aspx", "vcr/1_9_0/PaneInfo/Organizations.html")));
            }

            return(items.ToArray());
        }
        public void DeleteAssociation(int reminderID, int refID, ReferenceType refType)
        {
            try
            {
                LoginUser        loginUser    = TSAuthentication.GetLoginUser();
                TaskAssociations associations = new TaskAssociations(loginUser);
                associations.DeleteAssociation(reminderID, refID, refType);
                string description = String.Format("{0} deleted task association to {1} ", TSAuthentication.GetUser(loginUser).FirstLastName, Enum.GetName(typeof(ReferenceType), refType));
                TaskLogs.AddTaskLog(loginUser, reminderID, description);

                Reminder task = Reminders.GetReminder(loginUser, reminderID);
                if (task.UserID != null && loginUser.UserID != task.UserID)
                {
                    SendModifiedNotification(loginUser.UserID, task.ReminderID);
                }
            }
            catch (Exception ex)
            {
                DataUtils.LogException(UserSession.LoginUser, ex);
            }
        }
        public bool AddAssociation(int taskID, int refID, int refType)
        {
            LoginUser loginUser = TSAuthentication.GetLoginUser();

            try
            {
                TaskAssociation taskAssociation = (new TaskAssociations(loginUser).AddNewTaskAssociation());
                taskAssociation.TaskID      = taskID;
                taskAssociation.RefID       = refID;
                taskAssociation.RefType     = refType;
                taskAssociation.DateCreated = DateTime.UtcNow;
                taskAssociation.CreatorID   = loginUser.UserID;
                taskAssociation.Collection.Save();
                string description = String.Format("{0} added task association to {1}.", TSAuthentication.GetUser(loginUser).FirstLastName, Enum.GetName(typeof(ReferenceType), refType));
                TaskLogs.AddTaskLog(loginUser, taskID, description);

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

                if (refType == (int)ReferenceType.Contacts)
                {
                    TeamSupport.Data.User user = Users.GetUser(loginUser, refID);
                    taskAssociation             = (new TaskAssociations(loginUser).AddNewTaskAssociation());
                    taskAssociation.TaskID      = taskID;
                    taskAssociation.RefID       = user.OrganizationID;
                    taskAssociation.RefType     = (int)ReferenceType.Organizations;
                    taskAssociation.DateCreated = DateTime.UtcNow;
                    taskAssociation.CreatorID   = loginUser.UserID;
                    try
                    {
                        taskAssociation.Collection.Save();
                    }
                    catch (Exception e)
                    {
                        //TaskAssociation do not allow duplicates. This could happen when the company is already associated with the task.
                    }
                }

                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
        public TaskProxy NewTask(string data)
        {
            TaskJsonInfo info      = Newtonsoft.Json.JsonConvert.DeserializeObject <TaskJsonInfo>(data);
            LoginUser    loginUser = TSAuthentication.GetLoginUser();

            Task newTask = (new Tasks(loginUser)).AddNewTask();

            newTask.ParentID       = info.ParentID;
            newTask.OrganizationID = TSAuthentication.OrganizationID;
            newTask.Name           = info.Name;
            newTask.Description    = info.Description;
            newTask.UserID         = info.UserID;
            newTask.IsComplete     = info.IsComplete;

            if (newTask.IsComplete)
            {
                newTask.DateCompleted = DateTime.UtcNow;
            }

            newTask.DueDate = DataUtils.DateToUtc(loginUser, info.DueDate);

            newTask.Collection.Save();

            if (info.Reminder != null)
            {
                Reminder reminder = null;
                if (newTask.UserID == null)
                {
                    reminder = CreateReminder(loginUser, newTask.TaskID, info.Name, DataUtils.DateToUtc(loginUser, (DateTime)info.Reminder), false);
                }
                else
                {
                    reminder = CreateReminder(loginUser, newTask.TaskID, info.Name, DataUtils.DateToUtc(loginUser, (DateTime)info.Reminder), false, (int)newTask.UserID);
                }

                if (reminder != null)
                {
                    Tasks taskHelper = new Tasks(loginUser);
                    taskHelper.LoadByTaskID(newTask.TaskID);

                    if (taskHelper.Any())
                    {
                        taskHelper[0].ReminderID = reminder.ReminderID;
                        taskHelper.Save();
                    }
                }
            }

            foreach (int ticketID in info.Tickets)
            {
                AddAssociation(newTask.TaskID, ticketID, (int)ReferenceType.Tickets);
            }

            foreach (int productID in info.Products)
            {
                AddAssociation(newTask.TaskID, productID, (int)ReferenceType.Products);
            }

            foreach (int CompanyID in info.Company)
            {
                AddAssociation(newTask.TaskID, CompanyID, (int)ReferenceType.Organizations);
            }

            foreach (int UserID in info.Contacts)
            {
                AddAssociation(newTask.TaskID, UserID, (int)ReferenceType.Contacts);
            }

            foreach (int groupID in info.Groups)
            {
                AddAssociation(newTask.TaskID, groupID, (int)ReferenceType.Groups);
            }

            foreach (int UserID in info.User)
            {
                AddAssociation(newTask.TaskID, UserID, (int)ReferenceType.Users);
            }

            foreach (int ActivityID in info.Activities)
            {
                Notes notes = new Notes(TSAuthentication.GetLoginUser());
                notes.LoadByNoteID(ActivityID);

                if (notes.Count > 0)
                {
                    var note = notes[0];
                    if (note.RefType == ReferenceType.Organizations)
                    {
                        AddAssociation(newTask.TaskID, ActivityID, (int)ReferenceType.CompanyActivity);
                    }
                    else if (note.RefType == ReferenceType.Users)
                    {
                        AddAssociation(newTask.TaskID, ActivityID, (int)ReferenceType.ContactActivity);
                    }
                }
            }

            string description = String.Format("{0} created task.", TSAuthentication.GetUser(loginUser).FirstLastName);

            TaskLogs.AddTaskLog(loginUser, newTask.TaskID, description);

            if (newTask.UserID != null && loginUser.UserID != newTask.UserID)
            {
                SendAssignedNotification(loginUser.UserID, newTask.TaskID);
            }

            return(newTask.GetProxy());
        }