public void DoesNotRecreateExistingFields()
		{
			ICategoryRepository categoryRepository;
			const string categoryName = "category";

			List<FieldInfo> existingFields = new List<FieldInfo>();
			existingFields.Add(new FieldInfo("existingField1", FieldType.TextBox, "Existing field 1"));
			existingFields.Add(new FieldInfo("existingField2", FieldType.CheckBox, "Existing field 2"));

			using (Mocks.Record())
			{
				categoryRepository = Mocks.StrictMock<ICategoryRepository>();

				CustomFormSettings formSettings = new CustomFormSettings();
				formSettings.Fields = existingFields.ToCustomFieldList();

				Expect.Call(categoryRepository.GetFormSettings(categoryName)).Return(formSettings);
			}

			using (Mocks.Playback())
			{
				Migrator fm = new Migrator(categoryRepository, new PostRepository());
				fm.EnsureFields(categoryName, existingFields);
			}
		}
Пример #2
0
        public static CustomFormSettings Get()
        {
            CustomFormSettings cfs = ObjectManager.Get <CustomFormSettings>(DefaultCustomFormName);

            cfs.FormCategoryId = -1;
            cfs.CategoryId     = -1;

            return(cfs);
        }
		public void AddField(CustomFormSettings settings, CustomField field)
		{
			if (settings == null)
			{
				throw new ArgumentNullException("settings");
			}

			if (field == null)
			{
				throw new ArgumentNullException("field");
			}

			settings.Add(field);
			settings.Save();
		}
		public void CreatesNewFields()
		{
			ICategoryRepository categoryRepository;
			const string categoryName = "category";

			List<FieldInfo> newFields = new List<FieldInfo>();
			newFields.Add(new FieldInfo("newField1", FieldType.TextBox, "New field 1"));
			newFields.Add(new FieldInfo("newField2", FieldType.CheckBox, "New field 2"));

			using (Mocks.Record())
			{
				categoryRepository = Mocks.StrictMock<ICategoryRepository>();

				CustomFormSettings formSettings = new CustomFormSettings();
				formSettings.Fields = new List<CustomField>();
				Expect.Call(categoryRepository.GetFormSettings(categoryName)).Return(formSettings);

				foreach (FieldInfo field in newFields)
				{
					categoryRepository.AddField(formSettings, new CustomField());

					FieldInfo field1 = field;
					LastCall.Constraints(Is.Same(formSettings),
					                     Is.Matching(
					                     	(CustomField f) =>
					                     	f.Name == field1.FieldName && f.FieldType == field1.FieldType &&
					                     	f.Description == field1.Description));
				}
			}

			using (Mocks.Playback())
			{
				Migrator fm = new Migrator(categoryRepository, new PostRepository());
				fm.EnsureFields(categoryName, newFields);
			}
		}
		public void SaveFormSettings(CustomFormSettings settings)
		{
			if (settings == null)
			{
				throw new ArgumentNullException("settings");
			}

			settings.Save();
		}
		public void DeleteField(CustomFormSettings settings, string fieldName)
		{
			CustomField field = settings.Fields.Find(cf => cf.Name.Equals(fieldName, StringComparison.OrdinalIgnoreCase));
			if (field != null)
			{
				settings.Fields.Remove(field);
				settings.Save();
			}
		}
		public void ShouldCreateNewFieldsAndLeaveExistingFieldsIntact()
		{
			ICategoryRepository categoryRepository;
			const string categoryName = "category";

			List<FieldInfo> existingFields = new List<FieldInfo>();
			existingFields.Add(new FieldInfo("existingField1", FieldType.TextBox, "Existing field 1"));
			existingFields.Add(new FieldInfo("existingField2", FieldType.CheckBox, "Existing field 2"));

			List<FieldInfo> newFields = new List<FieldInfo>();
			newFields.Add(new FieldInfo("newField1", FieldType.TextBox, "New field 1"));
			newFields.Add(new FieldInfo("newField2", FieldType.CheckBox, "New field 2"));

			using (Mocks.Record())
			{
				categoryRepository = Mocks.StrictMock<ICategoryRepository>();

				CustomFormSettings formSettings = new CustomFormSettings();
				formSettings.Fields = existingFields.ToCustomFieldList();
				Expect.Call(categoryRepository.GetFormSettings(categoryName)).Return(formSettings);

				foreach (FieldInfo field in newFields)
				{
					categoryRepository.AddField(null, null);

					FieldInfo field1 = field;
					LastCall.Constraints(Is.Same(formSettings),
					                     Is.Matching(
					                     	(CustomField f) =>
					                     	f.Name == field1.FieldName && f.FieldType == field1.FieldType &&
					                     	f.Description == field1.Description));
				}
			}

			using (Mocks.Playback())
			{
				List<FieldInfo> merged = new List<FieldInfo>();
				merged.AddRange(newFields);
				merged.AddRange(existingFields);

				Migrator fm = new Migrator(categoryRepository, new PostRepository());
				fm.EnsureFields(categoryName, merged);
			}
		}
		public void ShouldDeleteChangedFields()
		{
			ICategoryRepository categoryRepository;
			IPostRepository postRepository;
			IMemento newState;
			IMemento oldState;
			const string categoryName = "category";

			using (Mocks.Record())
			{
				oldState = Mocks.StrictMock<IMemento>();
				Expect.Call(oldState.CategoryName).Return(categoryName);
				Expect.Call(oldState.Fields).Repeat.AtLeastOnce().Return(new Dictionary<Guid, FieldInfo>
				                                                         {
				                                                         	{
				                                                         		new Guid("{28E2469B-E568-4406-832D-3AD3F1EBE214}"),
				                                                         		new FieldInfo("oldFieldName",
				                                                         		              FieldType.TextBox,
				                                                         		              "Description")
				                                                         		}
				                                                         });

				newState = Mocks.StrictMock<IMemento>();
				Expect.Call(newState.CategoryName).Return(categoryName);
				Expect.Call(newState.Fields).Repeat.AtLeastOnce().Return(new Dictionary<Guid, FieldInfo>
				                                                         {
				                                                         	{
				                                                         		new Guid("{28E2469B-E568-4406-832D-3AD3F1EBE214}"),
				                                                         		new FieldInfo("newFieldName",
				                                                         		              FieldType.TextBox,
				                                                         		              "Description")
				                                                         		}
				                                                         });

				categoryRepository = Mocks.StrictMock<ICategoryRepository>();
				Category targetCategory = new Category { Id = int.MaxValue, Name = categoryName };
				Expect.Call(categoryRepository.GetCategory(categoryName)).Repeat.AtLeastOnce().Return(targetCategory);

				CustomFormSettings formSettings = new CustomFormSettings();
				formSettings.Fields = new List<CustomField>();
				Expect.Call(categoryRepository.GetFormSettings(categoryName)).Repeat.AtLeastOnce().Return(formSettings);

				categoryRepository.AddField(null, null);
				LastCall.Constraints(Is.Same(formSettings), Is.Matching((CustomField f) => f.Name == "newFieldName"));

				categoryRepository.DeleteField(null, null);
				LastCall.Constraints(Is.Same(formSettings), Is.Equal("oldFieldName"));

				// No posts to migrate.
				postRepository = Mocks.StrictMock<IPostRepository>();
				Expect.Call(postRepository.GetByCategory(categoryName)).Return(new PostCollection());
			}

			using (Mocks.Playback())
			{
				Migrator fm = new Migrator(categoryRepository, postRepository);
				fm.Migrate(new MigrationInfo(oldState, newState));
			}
		}
		public void ShouldSetDescriptionForExistingFieldsIfEmpty()
		{
			ICategoryRepository categoryRepository;
			const string categoryName = "category";

			List<FieldInfo> existingFields = new List<FieldInfo>();
			existingFields.Add(new FieldInfo("existingField1", FieldType.TextBox, "User-defined description"));
			existingFields.Add(new FieldInfo("existingField2", FieldType.CheckBox, String.Empty));

			List<FieldInfo> newFields = new List<FieldInfo>();
			newFields.Add(new FieldInfo("existingField1", FieldType.TextBox, "Field description 1"));
			newFields.Add(new FieldInfo("existingField2", FieldType.CheckBox, "Field description 2"));

			using (Mocks.Record())
			{
				categoryRepository = Mocks.StrictMock<ICategoryRepository>();

				CustomFormSettings formSettings = new CustomFormSettings();
				formSettings.Fields = existingFields.ToCustomFieldList();
				Expect.Call(categoryRepository.GetFormSettings(categoryName)).Return(formSettings);

				List<CustomField> expectedFormSettings = new List<CustomField>();
				expectedFormSettings.Add(existingFields.ToCustomFieldList()[0]);
				expectedFormSettings.Add(newFields.ToCustomFieldList()[1]);

				categoryRepository.SaveFormSettings(null);
				LastCall.Constraints(Is.Matching((CustomFormSettings cfs) =>
					{
						for (int i = 0; i < cfs.Fields.Count; i++)
						{
							CustomField field = cfs.Fields[i];
							CustomField expectedField = expectedFormSettings[i];
							if (expectedField.Name != field.Name || expectedField.Description != field.Description ||
							    expectedField.FieldType != field.FieldType)
							{
								return false;
							}
						}

						return true;
					}));
			}

			using (Mocks.Playback())
			{
				Migrator fm = new Migrator(categoryRepository, new PostRepository());
				fm.EnsureFields(categoryName, newFields);
			}
		}
Пример #10
0
        public static CustomFormSettings Get(Category category, bool processFormInheritance)
        {
            if (category == null)
            {
                return(Get());
            }

            CustomFormSettings cfs = ObjectManager.Get <CustomFormSettings>("CustomFormSettings-" + category.Id);

            cfs.FormCategoryId = category.Id;

            if (processFormInheritance)
            {
                CustomFormSettings combinedCfs = new CustomFormSettings();
                combinedCfs.Name           = category.Name;
                combinedCfs.FormCategoryId = category.Id;
                combinedCfs.IsNew          = cfs.IsNew;
                combinedCfs.Fields         = new List <CustomField>();

                if (cfs.Fields != null)
                {
                    foreach (CustomField field in cfs.Fields)
                    {
                        combinedCfs.Fields.Add(field);
                    }
                }

                CustomFormSettings cfs2;
                if (category.ParentId > 0)
                {
                    cfs2 = ObjectManager.Get <CustomFormSettings>("CustomFormSettings-" + category.ParentId);

                    if (cfs2.Fields != null)
                    {
                        foreach (CustomField field in cfs2.Fields)
                        {
                            combinedCfs.Fields.Add(field);
                        }
                    }

                    if (combinedCfs.IsNew)
                    {
                        combinedCfs.FormCategoryId = category.ParentId;
                        combinedCfs.IsNew          = false;
                    }
                }

                cfs2 = Get();
                if (cfs2.Fields != null)
                {
                    foreach (CustomField field in cfs2.Fields)
                    {
                        combinedCfs.Fields.Add(field);
                    }
                }

                if (combinedCfs.IsNew)
                {
                    combinedCfs.FormCategoryId = -1;
                    combinedCfs.IsNew          = false;
                }

                cfs = combinedCfs;
            }

            cfs.CategoryId = category.Id;

            return(cfs);
        }
Пример #11
0
        public static CustomFormSettings Get(Category category, bool processFormInheritance)
        {
            if (category == null)
                return Get();

            CustomFormSettings cfs = ObjectManager.Get<CustomFormSettings>("CustomFormSettings-" + category.Id);
            cfs.FormCategoryId = category.Id;

            if (processFormInheritance)
            {
                CustomFormSettings combinedCfs = new CustomFormSettings();
                combinedCfs.Name = category.Name;
                combinedCfs.FormCategoryId = category.Id;
                combinedCfs.IsNew = cfs.IsNew;
                combinedCfs.Fields = new List<CustomField>();

                if (cfs.Fields != null)
                {
                    foreach (CustomField field in cfs.Fields)
                    {
                        combinedCfs.Fields.Add(field);
                    }
                }

                CustomFormSettings cfs2;
                if (category.ParentId > 0)
                {
                    cfs2 = ObjectManager.Get<CustomFormSettings>("CustomFormSettings-" + category.ParentId);

                    if (cfs2.Fields != null)
                    {
                        foreach (CustomField field in cfs2.Fields)
                        {
                            combinedCfs.Fields.Add(field);
                        }
                    }

                    if (combinedCfs.IsNew)
                    {
                        combinedCfs.FormCategoryId = category.ParentId;
                        combinedCfs.IsNew = false;
                    }
                }

                cfs2 = Get();
                if (cfs2.Fields != null)
                {
                    foreach (CustomField field in cfs2.Fields)
                    {
                        combinedCfs.Fields.Add(field);
                    }
                }

                if (combinedCfs.IsNew)
                {
                    combinedCfs.FormCategoryId = -1;
                    combinedCfs.IsNew = false;
                }

                cfs = combinedCfs;
            }

            cfs.CategoryId = category.Id;

            return cfs;
        }
Пример #12
0
		/// <summary>
		/// Sorts the fields according the order of the fields in the <paramref name="fields"/> list.
		/// </summary>
		/// <param name="fields">The fields.</param>
		/// <param name="formSettings">The form settings.</param>
		void SortFields(List<FieldInfo> fields, CustomFormSettings formSettings)
		{
			string[] fieldNames = fields.ConvertAll(field => field.FieldName).ToArray();

			formSettings.Fields.Sort(delegate(CustomField x, CustomField y)
				{
					if (Array.IndexOf(fieldNames, x.Name) < Array.IndexOf(fieldNames, y.Name))
					{
						return -1;
					}

					if (Array.IndexOf(fieldNames, x.Name) > Array.IndexOf(fieldNames, y.Name))
					{
						return 1;
					}

					return 0;
				});
		}
Пример #13
0
		void CreateField(FieldInfo field, CustomFormSettings formSettings)
		{
			CustomField newField = new CustomField
			                       {
			                       	Id = Guid.NewGuid(),
			                       	Enabled = true,
			                       	Name = field.FieldName,
			                       	FieldType = field.FieldType,
			                       	Description = field.Description
			                       };

			_categoryRepository.AddField(formSettings, newField);
		}
Пример #14
0
		void EnsureFieldDescription(FieldInfo field, CustomFormSettings formSettings)
		{
			CustomField customField =
				formSettings.Fields.Find(f => Util.AreEqualIgnoreCase(field.FieldName, f.Name));

			if (!customField.Description.IsNullOrEmpty())
			{
				return;
			}

			if (String.Equals(customField.Description, field.Description, StringComparison.Ordinal))
			{
				return;
			}

			customField.Description = field.Description;
			_categoryRepository.SaveFormSettings(formSettings);
		}
Пример #15
0
        private string GetBreadCrumbs()
        {
            Urls          urls   = new Urls();
            StringBuilder crumbs = new StringBuilder();

            if (Page.MasterPageFile.EndsWith("AdminModal.master"))
            {
                crumbs.Append("<div class=\"breadcrumbs_modal\">");
            }
            else
            {
                crumbs.Append("<div class=\"breadcrumbs\">");
            }

            switch (_sectionName)
            {
            case Section.ThemeEdit:
            {
                crumbs.Append(GetHyperLink("Presentation", ResolveUrl("~/graffiti-admin/presentation/"), true));
                crumbs.Append(GetHyperLink("Themes", ResolveUrl("~/graffiti-admin/presentation/themes/"), true));

                string theme = HttpContext.Current.Request.QueryString[QueryStringKey.Theme];
                crumbs.Append(GetHyperLink(theme, String.Format("EditTheme.aspx?{0}={1}", QueryStringKey.Theme, theme), false));
            }
            break;

            case Section.ConfigureTheme:
            {
                crumbs.Append(GetHyperLink("Presentation", ResolveUrl("~/graffiti-admin/presentation/"), true));
                crumbs.Append(GetHyperLink("Themes", ResolveUrl("~/graffiti-admin/presentation/themes/"), true));

                string theme = HttpContext.Current.Request.QueryString[QueryStringKey.Theme];
                crumbs.Append(GetHyperLink(theme, String.Format("EditTheme.aspx?{0}={1}", QueryStringKey.Theme, theme), true));

                crumbs.Append(GetHyperLink("Configure Theme",
                                           ResolveUrl("~/graffiti-admin/presentation/themes/ConfigureTheme.aspx?" +
                                                      QueryStringKey.Theme + "=" + theme), false));
            }
            break;

            case Section.Widget:

                crumbs.Append(GetHyperLink("Presentation", ResolveUrl("~/graffiti-admin/presentation/"), true));
                crumbs.Append(GetHyperLink("Widgets", ResolveUrl("~/graffiti-admin/presentation/widgets/"), true));

                break;

            case Section.WidgetEdit:

                crumbs.Append(GetHyperLink("Presentation", ResolveUrl("~/graffiti-admin/presentation/"), true));
                crumbs.Append(GetHyperLink("Widgets", ResolveUrl("~/graffiti-admin/presentation/widgets/"), true));

                Widget widget = Widgets.Fetch(new Guid(HttpContext.Current.Request.QueryString[QueryStringKey.Id]));
                crumbs.Append(GetHyperLink(widget.Name, String.Format("edit.aspx?{0}={1}", QueryStringKey.Id, widget.Id), false));

                break;

            case Section.SiteSettings:

                crumbs.Append(GetHyperLink("Site Options", ResolveUrl("~/graffiti-admin/site-options/"), true));
                crumbs.Append(GetHyperLink("Settings", ResolveUrl("~/graffiti-admin/site-options/settings/"), false));

                break;

            case Section.Configuration:

                crumbs.Append(GetHyperLink("Site Options", ResolveUrl("~/graffiti-admin/site-options/"), true));
                crumbs.Append(GetHyperLink("Configuration", ResolveUrl("~/graffiti-admin/site-options/configuration/"), false));

                break;

            case Section.Utilities:

                crumbs.Append(GetHyperLink("Site Options", ResolveUrl("~/graffiti-admin/site-options/"), true));
                crumbs.Append(GetHyperLink("Utilities", ResolveUrl("~/graffiti-admin/site-options/utilities/"), false));

                break;

            case Section.RebuildPages:

                crumbs.Append(GetHyperLink("Site Options", ResolveUrl("~/graffiti-admin/site-options/"), true));
                crumbs.Append(GetHyperLink("Utilities", ResolveUrl("~/graffiti-admin/site-options/utilities/"), true));
                crumbs.Append(GetHyperLink("Rebuild Pages", ResolveUrl("~/graffiti-admin/site-options/utilities/RebuildPages.aspx"),
                                           false));

                break;

            case Section.Logs:

                crumbs.Append(GetHyperLink("Site Options", ResolveUrl("~/graffiti-admin/site-options/"), true));
                crumbs.Append(GetHyperLink("Utilities", ResolveUrl("~/graffiti-admin/site-options/utilities/"), true));
                crumbs.Append(GetHyperLink("Logs", ResolveUrl("~/graffiti-admin/site-options/utilities/LogViewer.aspx"), false));

                break;

            case Section.Migrator:

                crumbs.Append(GetHyperLink("Site Options", ResolveUrl("~/graffiti-admin/site-options/"), true));
                crumbs.Append(GetHyperLink("Utilities", ResolveUrl("~/graffiti-admin/site-options/utilities/"), true));
                crumbs.Append(GetHyperLink("Migrator", ResolveUrl("~/graffiti-admin/site-options/utilities/migrator/"), false));

                break;

            case Section.Comments:

                crumbs.Append(GetHyperLink("Site Options", ResolveUrl("~/graffiti-admin/site-options/"), true));
                crumbs.Append(GetHyperLink("Comments", ResolveUrl("~/graffiti-admin/site-options/comments/"), false));

                break;


            case Section.CustomFields:

                crumbs.Append(GetHyperLink("Site Options", ResolveUrl("~/graffiti-admin/site-options/"), true));
                crumbs.Append(GetHyperLink("Custom Fields", ResolveUrl("~/graffiti-admin/site-options/custom-fields/"), true));

                string customFieldId   = HttpContext.Current.Request.QueryString[QueryStringKey.Id];
                int    fieldCategoryId = int.Parse(HttpContext.Current.Request.QueryString["category"] ?? "-1");

                if (!String.IsNullOrEmpty(customFieldId))
                {
                    CustomFormSettings csf = CustomFormSettings.Get(fieldCategoryId, false);

                    CustomField cf = null;
                    Guid        g  = new Guid(customFieldId);
                    foreach (CustomField cfx in csf.Fields)
                    {
                        if (cfx.Id == g)
                        {
                            cf = cfx;
                            break;
                        }
                    }

                    if (cf != null)
                    {
                        crumbs.Append(GetHyperLink(cf.Name, ResolveUrl("~/graffiti-admin/site-options/custom-fields/?id=" + cf.Id), false));
                    }
                }

                break;

            case Section.Themes:

                crumbs.Append(GetHyperLink("Presentation", ResolveUrl("~/graffiti-admin/presentation/"), true));
                crumbs.Append(GetHyperLink("Themes", ResolveUrl("~/graffiti-admin/presentation/themes/"), false));

                break;

            case Section.SortHomePosts:

                crumbs.Append(GetHyperLink("Site Options", ResolveUrl("~/graffiti-admin/site-options/"), true));
                crumbs.Append(GetHyperLink("Home Page", ResolveUrl("~/graffiti-admin/site-options/homesort/"), false));

                break;

            case Section.Licensing:

                crumbs.Append(GetHyperLink("Site Options", ResolveUrl("~/graffiti-admin/site-options/"), true));
                crumbs.Append(GetHyperLink("Licensing", ResolveUrl("~/graffiti-admin/site-options/licensing/"), false));

                break;

            case Section.Categories:
            {
                string id = HttpContext.Current.Request.QueryString[QueryStringKey.Id];

                if (String.IsNullOrEmpty(id))
                {
                    return(string.Empty);
                }

                var categories = new List <Category>();

                Category c = new Category(id);
                categories.Add(c);

                Category parent;

                if (c.ParentId != -1)
                {
                    parent = c;

                    bool noMoreParents = false;

                    while (!noMoreParents)
                    {
                        parent = new Category(parent.ParentId);
                        if (parent.Id != 0)
                        {
                            categories.Insert(0, parent);
                        }
                        else
                        {
                            noMoreParents = true;
                        }
                    }
                }

                crumbs.Append(GetHyperLink("Categories", ResolveUrl("~/graffiti-admin/categories/"), true));

                int counter  = 0;
                int catCount = categories.Count;

                foreach (Category tempcat in categories)
                {
                    counter++;

                    bool addArrow = counter == catCount ? false : true;

                    crumbs.Append(GetHyperLink(tempcat.Name, ResolveUrl("~/graffiti-admin/categories/?id=" + tempcat.Id), addArrow));
                }
            }
            break;

            case Section.SortPosts:
            {
                string id = HttpContext.Current.Request.QueryString[QueryStringKey.Id];

                if (String.IsNullOrEmpty(id))
                {
                    return(string.Empty);
                }

                var categories = new List <Category>();

                Category c = new Category(id);
                categories.Add(c);

                Category parent;

                if (c.ParentId != -1)
                {
                    parent = c;

                    bool noMoreParents = false;

                    while (!noMoreParents)
                    {
                        parent = new Category(parent.ParentId);
                        if (parent.Id != 0)
                        {
                            categories.Insert(0, parent);
                        }
                        else
                        {
                            noMoreParents = true;
                        }
                    }
                }

                crumbs.Append(GetHyperLink("Categories", ResolveUrl("~/graffiti-admin/categories/"), true));
                foreach (Category tempcat in categories)
                {
                    crumbs.Append(GetHyperLink(tempcat.Name, ResolveUrl("~/graffiti-admin/categories/?id=" + tempcat.Id), true));
                }

                crumbs.Append(GetHyperLink("Order Posts", ResolveUrl("~/graffiti-admin/categories/PostSortOrder.aspx?id=" + id),
                                           false));
            }
            break;


            case Section.SiteComments:

                string commentId = HttpContext.Current.Request.QueryString[QueryStringKey.Id];

                if (String.IsNullOrEmpty(commentId))
                {
                    return(string.Empty);
                }

                Comment comment = new Comment(commentId);

                crumbs.Append(GetHyperLink("Comments", ResolveUrl("~/graffiti-admin/comments/"), true));
                crumbs.Append(GetHyperLink(comment.Name + " @ " + comment.Published,
                                           ResolveUrl("~/graffiti-admin/comments/?id=" + comment.Id), false));

                break;

            case Section.Navigation:

                crumbs.Append(GetHyperLink("Presentation", ResolveUrl("~/graffiti-admin/presentation/"), true));
                crumbs.Append(GetHyperLink("Navigation", ResolveUrl("~/graffiti-admin/presentation/navigation/"), false));

                break;

            case Section.UserManagement:

                crumbs.Append(GetHyperLink("User Management", ResolveUrl("~/graffiti-admin/user-management/"), true));

                string user = HttpContext.Current.Request.QueryString[QueryStringKey.User];

                if (!String.IsNullOrEmpty(user))
                {
                    crumbs.Append(GetHyperLink("Users", ResolveUrl("~/graffiti-admin/user-management/users"), true));

                    IGraffitiUser graffitiUser = GraffitiUsers.GetUser(user);
                    crumbs.Append(GetHyperLink(graffitiUser.Name,
                                               ResolveUrl("~/graffiti-admin/user-management/users/?user="******"Users", ResolveUrl("~/graffiti-admin/user-management/users"), false));
                }

                break;

            case Section.Roles:

                crumbs.Append(GetHyperLink("User Management", ResolveUrl("~/graffiti-admin/user-management/"), true));

                string role =
                    HttpUtility.HtmlEncode(
                        HttpContext.Current.Server.UrlDecode(HttpContext.Current.Request.QueryString[QueryStringKey.Role]));

                if (!String.IsNullOrEmpty(role))
                {
                    crumbs.Append(GetHyperLink("Roles", ResolveUrl("~/graffiti-admin/user-management/roles"), true));

                    crumbs.Append(GetHyperLink(role, ResolveUrl("~/graffiti-admin/user-management/roles/?role=" + role), false));
                }
                else
                {
                    crumbs.Append(GetHyperLink("Roles", ResolveUrl("~/graffiti-admin/user-management/roles"), false));
                }

                break;

            case Section.ChangePassword:

                string cpUser = HttpContext.Current.Request.QueryString[QueryStringKey.User];

                if (String.IsNullOrEmpty(cpUser))
                {
                    return(string.Empty);
                }

                IGraffitiUser graffitiUser1 = GraffitiUsers.GetUser(cpUser);

                crumbs.Append(GetHyperLink("User Management", ResolveUrl("~/graffiti-admin/user-management/"), true));
                crumbs.Append(GetHyperLink("Users", ResolveUrl("~/graffiti-admin/user-management/users/"), true));
                crumbs.Append(GetHyperLink(graffitiUser1.Name,
                                           ResolveUrl("~/graffiti-admin/user-management/users/?user="******"Change Password",
                                           ResolveUrl("~/graffiti-admin/user-management/users/changepassword.aspx?user="******"Site Options", ResolveUrl("~/graffiti-admin/site-options/"), true));
                crumbs.Append(GetHyperLink("Plug-Ins", ResolveUrl("~/graffiti-admin/site-options/plug-ins/"), false));

                break;

            case Section.PlugInsEdit:

                crumbs.Append(GetHyperLink("Site Options", ResolveUrl("~/graffiti-admin/site-options/"), true));
                crumbs.Append(GetHyperLink("Plug-Ins", ResolveUrl("~/graffiti-admin/site-options/plug-ins/"), true));

                EventDetails ed = Core.Events.GetEvent(HttpContext.Current.Request.QueryString["t"]);

                crumbs.Append(GetHyperLink(ed.Event.Name,
                                           ResolveUrl("~/graffiti-admin/site-options/plug-ins/edit.aspx?t=") +
                                           HttpContext.Current.Request.QueryString["t"], false));

                break;

            case Section.Packages:

                crumbs.Append(GetHyperLink("Site Options", ResolveUrl("~/graffiti-admin/site-options/"), true));
                crumbs.Append(GetHyperLink("Packages", ResolveUrl("~/graffiti-admin/site-options/packages/"), false));

                break;

            case Section.EmailSettings:

                crumbs.Append(GetHyperLink("Site Options", ResolveUrl("~/graffiti-admin/site-options/"), true));
                crumbs.Append(GetHyperLink("Email Settings", ResolveUrl("~/graffiti-admin/site-options/email-settings/"), false));

                break;

            case Section.WidgetMarketplace:

                crumbs.Append(GetHyperLink("All Widgets", urls.AdminMarketplace("Widgets"), true));

                CatalogInfo widgets = Marketplace.Marketplace.Catalogs[CatalogType.Widgets];

                int    categoryId = 0;
                string category   = HttpContext.Current.Request.QueryString["category"];
                if (!string.IsNullOrEmpty(category))
                {
                    try
                    {
                        categoryId = int.Parse(category);
                    }
                    catch
                    {
                    }
                }

                if ((categoryId != 0) && widgets.Categories.ContainsKey(categoryId))
                {
                    CategoryInfo categoryInfo = widgets.Categories[categoryId];
                    crumbs.Append(GetHyperLink(categoryInfo.Name,
                                               urls.AdminMarketplace("Widgets") + "&category=" + categoryInfo.Id.ToString(), false));
                }

                string creatorId = string.Empty;
                if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["creator"]))
                {
                    creatorId = HttpUtility.UrlDecode(HttpContext.Current.Request.QueryString["creator"]);
                }

                if (!string.IsNullOrEmpty(creatorId) && (Marketplace.Marketplace.Creators.ContainsKey(creatorId)))
                {
                    CreatorInfo creatorInfo = Marketplace.Marketplace.Creators[creatorId];
                    crumbs.Append(GetHyperLink(creatorInfo.Name,
                                               urls.AdminMarketplace("Widgets") + "&creator=" + HttpUtility.UrlEncode(creatorInfo.Id),
                                               false));
                }

                int    itemId = 0;
                string item   = HttpContext.Current.Request.QueryString["item"];
                if (!string.IsNullOrEmpty(item))
                {
                    try
                    {
                        itemId = int.Parse(item);
                    }
                    catch
                    {
                    }
                }

                if ((itemId != 0) && (widgets.Items.ContainsKey(itemId)))
                {
                    ItemInfo     itemInfo     = widgets.Items[itemId];
                    CategoryInfo categoryInfo = itemInfo.Category;
                    if (categoryInfo != null)
                    {
                        crumbs.Append(GetHyperLink(categoryInfo.Name,
                                                   urls.AdminMarketplace("Widgets") + "&category=" + categoryInfo.Id.ToString(), true));
                        crumbs.Append(GetHyperLink(itemInfo.Name, urls.AdminMarketplaceItem("Widgets", itemInfo.Id), false));
                    }
                }

                break;

            case Section.ThemeMarketplace:

                crumbs.Append(GetHyperLink("All Themes", urls.AdminMarketplace("Themes"), true));

                CatalogInfo themeCatalog = Marketplace.Marketplace.Catalogs[CatalogType.Themes];

                categoryId = 0;
                category   = HttpContext.Current.Request.QueryString["category"];
                if (!string.IsNullOrEmpty(category))
                {
                    try
                    {
                        categoryId = int.Parse(category);
                    }
                    catch
                    {
                    }
                }

                if ((categoryId != 0) && (themeCatalog.Categories.ContainsKey(categoryId)))
                {
                    CategoryInfo categoryInfo = themeCatalog.Categories[categoryId];
                    crumbs.Append(GetHyperLink(categoryInfo.Name,
                                               urls.AdminMarketplace("Themes") + "&category=" + categoryInfo.Id.ToString(), false));
                }

                creatorId = string.Empty;
                if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["creator"]))
                {
                    creatorId = HttpUtility.UrlDecode(HttpContext.Current.Request.QueryString["creator"]);
                }

                if (!string.IsNullOrEmpty(creatorId) && (Marketplace.Marketplace.Creators.ContainsKey(creatorId)))
                {
                    CreatorInfo creatorInfo = Marketplace.Marketplace.Creators[creatorId];
                    crumbs.Append(GetHyperLink(creatorInfo.Name,
                                               urls.AdminMarketplace("Themes") + "&creator=" + HttpUtility.UrlEncode(creatorInfo.Id),
                                               false));
                }

                itemId = 0;
                item   = HttpContext.Current.Request.QueryString["item"];
                if (!string.IsNullOrEmpty(item))
                {
                    try
                    {
                        itemId = int.Parse(item);
                    }
                    catch
                    {
                    }
                }

                if ((itemId != 0) && (themeCatalog.Items.ContainsKey(itemId)))
                {
                    ItemInfo     itemInfo     = themeCatalog.Items[itemId];
                    CategoryInfo categoryInfo = itemInfo.Category;
                    if (categoryInfo != null)
                    {
                        crumbs.Append(GetHyperLink(categoryInfo.Name,
                                                   urls.AdminMarketplace("Themes") + "&category=" + categoryInfo.Id.ToString(), true));
                        crumbs.Append(GetHyperLink(itemInfo.Name, urls.AdminMarketplaceItem("Themes", itemInfo.Id), false));
                    }
                }

                break;

            case Section.PluginMarketplace:

                crumbs.Append(GetHyperLink("All Plugins", urls.AdminMarketplace("Plugins"), true));

                CatalogInfo plugins = Marketplace.Marketplace.Catalogs[CatalogType.Plugins];

                categoryId = 0;
                category   = HttpContext.Current.Request.QueryString["category"];
                if (!string.IsNullOrEmpty(category))
                {
                    try
                    {
                        categoryId = int.Parse(category);
                    }
                    catch
                    {
                    }
                }

                if ((categoryId != 0) && plugins.Categories.ContainsKey(categoryId))
                {
                    CategoryInfo categoryInfo = plugins.Categories[categoryId];
                    crumbs.Append(GetHyperLink(categoryInfo.Name,
                                               urls.AdminMarketplace("Plugins") + "&category=" + categoryInfo.Id.ToString(), false));
                }

                creatorId = string.Empty;
                if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["creator"]))
                {
                    creatorId = HttpUtility.UrlDecode(HttpContext.Current.Request.QueryString["creator"]);
                }

                if (!string.IsNullOrEmpty(creatorId) && (Marketplace.Marketplace.Creators.ContainsKey(creatorId)))
                {
                    CreatorInfo creatorInfo = Marketplace.Marketplace.Creators[creatorId];
                    crumbs.Append(GetHyperLink(creatorInfo.Name,
                                               urls.AdminMarketplace("Plugins") + "&creator=" + HttpUtility.UrlEncode(creatorInfo.Id),
                                               false));
                }

                itemId = 0;
                item   = HttpContext.Current.Request.QueryString["item"];
                if (!string.IsNullOrEmpty(item))
                {
                    try
                    {
                        itemId = int.Parse(item);
                    }
                    catch
                    {
                    }
                }

                if ((itemId != 0) && (plugins.Items.ContainsKey(itemId)))
                {
                    ItemInfo     itemInfo     = plugins.Items[itemId];
                    CategoryInfo categoryInfo = itemInfo.Category;
                    if (categoryInfo != null)
                    {
                        crumbs.Append(GetHyperLink(categoryInfo.Name,
                                                   urls.AdminMarketplace("Plugins") + "&category=" + categoryInfo.Id.ToString(), true));
                        crumbs.Append(GetHyperLink(itemInfo.Name, urls.AdminMarketplaceItem("Plugins", itemInfo.Id), false));
                    }
                }

                break;

                // more breadcrumb logic here, add a value to the enum
            }

            crumbs.Append("</div>");

            return(crumbs.ToString());
        }