Пример #1
0
		/// <summary>
		/// Finds the specified category.
		/// </summary>
		/// <param name="category">The category.</param>
		/// <returns></returns>
		public Category Find(Category category)
		{
			foreach (Category lCategoryItem in this)
				if (lCategoryItem == category) // Found it
					return lCategoryItem;
			return null; // Not found
		}
Пример #2
0
		/// <summary>
		/// Indexes the of.
		/// </summary>
		/// <param name="category">The category.</param>
		/// <returns></returns>
		public int IndexOf(Category category)
		{
			for (int i = 0; i < List.Count; i++)
				if (this[i] == category) // Found it
					return i;
			return -1;
		}
Пример #3
0
		/// <summary>
		/// Creates the domain object.
		/// </summary>
		/// <param name="listItem">The list item.</param>
		/// <returns></returns>
		public static Category CreateDomainObject(SharePointListItem listItem)
		{
			Category category = new Category(listItem.Id, listItem["Title"]);

			category.SortOrder = Convert.ToInt32(listItem["SortOrder"]);

			return category;
		}
Пример #4
0
		/// <summary>
		/// Creates the dto.
		/// </summary>
		/// <param name="category">The category.</param>
		/// <returns></returns>
		public static SharePointListItem CreateDto(Category category)
		{
			string[] values = {
				"Title", category.Name,
				"SortOrder", category.SortOrder.ToString(),
			};

			return new SharePointListItem(category.Id, values);
		}
Пример #5
0
		private void LoadControlValues()
		{
			categoryId = ValidInt(HttpContext.Current.Request.QueryString["category"]);
			if (categoryId == 0)
				category = new Category("New Category");
			else
				category = RepositoryRegistry.CategoryRepository.GetById(categoryId);
			txtName.Text = category.Name;
		}
Пример #6
0
		/// <summary>
		/// Saves the specified category.
		/// </summary>
		/// <param name="category">The category.</param>
		/// <returns></returns>
		public int Save(Category category)
		{
			SharePointListItem listItem = CategoryMapper.CreateDto(category);
			int categoryId;

			if (listItem.Id == 0)
				categoryId = provider.AddListItem(ForumConstants.Lists_Category, listItem);
			else
				categoryId = provider.UpdateListItem(ForumConstants.Lists_Category, listItem);

			return categoryId;
		}
Пример #7
0
		private void btnExecute_Click(object sender, EventArgs e)
		{
			try
			{
				Random rnd = new Random();
				int max1, max2, max3, max4;
				
				max1 = rnd.Next(2, 5);
				for (int c = 1; c < max1; c++)
				{
					string categoryName = string.Format("Test Category {0}", c+1);
					Category category = new Category(categoryName);
					int catId = RepositoryRegistry.CategoryRepository.Save(category);
					
					max2 = rnd.Next(3, 8);
					for (int f = 1; f < max2; f++)
					{
						string forumName = string.Format("Test Forum {0} in category {1}", f+1, categoryName);
						Forum forum = new Forum(catId, forumName);
						forum.Description = "This is just a test forum, nothing special here.";
						int forumId = RepositoryRegistry.ForumRepository.Save(forum);
						
						max3 = rnd.Next(3, 10);
						for (int t = 1; t < max3; t++)
						{
							string topicName = string.Format("Test Topic {0} in forum {1}", t+1, forumName);
							Topic topic = new Topic(forumId, topicName);
							topic.TopicStarterId = 1;
							int topicId = RepositoryRegistry.TopicRepository.Save(topic);
							
							max4 = rnd.Next(3, 10);
							for (int m = 0; m < max4; m++)
							{
								Message message = new Message(topicId);
								message.Name = "Just a test message.";
								message.Body = "You'll want to delete these messages. Use the Admin function \"Delete Forums\" to clear them out.";
								message.UserId = 1;
								RepositoryRegistry.MessageRepository.Save(message);
							}
						}
					}
				}
			}
			catch (Exception)
			{
				throw;
			}
			finally
			{
				RedirectToParent();
			}
		}
Пример #8
0
		public void UserShouldHaveAccess()
		{
			ForumUser user = new ForumUser();
			Category category = new Category("Test");
			Assert.AreEqual(true, category.HasAccess(user, Permission.Rights.Add));
		}
Пример #9
0
		/// <summary>
		/// Determines whether [contains] [the specified category].
		/// </summary>
		/// <param name="category">The category.</param>
		/// <returns>
		/// 	<c>true</c> if [contains] [the specified category]; otherwise, <c>false</c>.
		/// </returns>
		public bool Contains(Category category)
		{
			return (Find(category) != null);
		}
Пример #10
0
		/// <summary>
		/// Removes the specified category.
		/// </summary>
		/// <param name="category">The category.</param>
		public void Remove(Category category)
		{
			List.Remove(category);
		}
Пример #11
0
		/// <summary>
		/// Inserts the specified index.
		/// </summary>
		/// <param name="index">The index.</param>
		/// <param name="category">The category.</param>
		public void Insert(int index, Category category)
		{
			List.Insert(index, category);
		}
Пример #12
0
		/// <summary>
		/// Adds the specified category.
		/// </summary>
		/// <param name="category">The category.</param>
		/// <returns></returns>
		public int Add(Category category)
		{
			return List.Add(category);
		}
Пример #13
0
		public int Save(Category category)
		{
			return _dao.Save(category);
		}