public async Task <UserSetting> GetSettingsForUserAsync(string userId)
        {
            var isHelpDeskUser = Context.SecurityProvider.IsTdHelpDeskUser ||
                                 Context.SecurityProvider.IsTdAdministrator;
            var settings = await Context.UserSettings.FindAsync(userId);

            //ensure settings exist
            if (settings == null)
            {
                settings = UserSetting.GetDefaultSettingsForUser(userId, isHelpDeskUser);
                using (var tempCtx = new TdDomainContext())
                {
                    await tempCtx.UserSettingsManager.AddOrUpdateSettingsForUser(settings);

                    await tempCtx.SaveChangesAsync();
                }
            }
            //ensure that the user has all required lists for their role, if not blow away list settings and recreate
            if (!settings.ListSettings.HasRequiredDefaultListSettings(isHelpDeskUser))
            {
                settings.ListSettings = new UserTicketListSettingsCollection
                {
                    UserTicketListSetting.GetDefaultListSettings(userId, isHelpDeskUser)
                };
                using (var tempCtx = new TdDomainContext())
                {
                    await tempCtx.UserSettingsManager.AddOrUpdateSettingsForUser(settings);

                    await tempCtx.SaveChangesAsync();
                }
            }
            return(settings);
        }
        public async Task ResetAllListSettingsForUserAsync(string userId)
        {
            var settings = await GetSettingsForUserAsync(userId);

            settings.ListSettings = new UserTicketListSettingsCollection
            {
                UserTicketListSetting.GetDefaultListSettings(userId, Context.SecurityProvider.IsTdHelpDeskUser || Context.SecurityProvider.IsTdAdministrator)
            };
        }
Beispiel #3
0
        public static IHtmlString SortableColumnHeader(this AjaxHelper helper, HtmlHelper htmlHelper,
                                                       UserTicketListSetting currentDisplayPreferences, int currentPage, string action, string listName, string sortColumn,
                                                       string linkText, AjaxOptions ajaxOptions)
        {
            var imgContent   = string.Empty;
            var linkContent  = linkText;
            var indexContent = string.Empty;
            var sortColumns  = currentDisplayPreferences.SortColumns;
            var cColumn      = sortColumns.SingleOrDefault(sc => sc.ColumnName == sortColumn);

            if (cColumn != null)
            {
                var uh     = new UrlHelper(helper.ViewContext.RequestContext);
                var imgSrc =
                    uh.Content((cColumn.SortDirection == ColumnSortDirection.Ascending)
                        ? "~/Content/Images/arrow_top.png"
                        : "~/Content/Images/arrow_down.png");
                imgContent = string.Format("<img src='{0}' alt='{1}' />", imgSrc, cColumn.SortDirection.ToString());

                var idx = sortColumns.IndexOf(cColumn) + 1;
                indexContent = string.Format("<sup>[{0}]</sup>", idx);
            }

            var sb = new StringBuilder();

            sb.AppendLine("<span style='white-space:nowrap;'>");
            var lLine =
                // ReSharper disable once Mvc.ActionNotResolved
                helper.ActionLink(linkContent, "SortList", new { page = currentPage, ListName = listName, ColumnName = sortColumn },
                                  ajaxOptions,
                                  new
            {
                OnMouseDown = "ticketCenter.sorts.setShiftStatus(event);",
                Title       = Strings.RemoveColumnsFromSort
            }).ToString();


            sb.AppendLine(lLine + indexContent);
            sb.AppendLine(imgContent);
            sb.AppendLine("</span>");
            return(MvcHtmlString.Create(sb.ToString()));
        }
Beispiel #4
0
 public FilterBarViewModel(UserTicketListSetting currentListSetting)
 {
     CurrentListSetting = currentListSetting;
     RoleManager        = DependencyResolver.Current.GetService <TicketDeskRoleManager>();
     UserManager        = DependencyResolver.Current.GetService <TicketDeskUserManager>();
 }