//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;
using CommunityServer.Components;
using CommunityServer.Components.Enumerations;

namespace CommunityServer.Galleries.Components
{
	/// <summary>
	/// Summary description for GalleryUserCookie.
	/// </summary>
	[Obsolete ("User based photo sorting has been dropped for CS 1.2")]
	public class GalleryUserCookie : UserCookie
	{

		private string appKey = CSContext.Current.ApplicationKey;

		public GalleryUserCookie( User user ) : base(user)
		{ }

		public GalleryThreadSortBy ThreadSortBy
		{
			get
			{
				if(userCookie["GalleryThreadSortBy"] == null)
					return Galleries.GetGallery(appKey).ThreadSortBy;
				else
					return (GalleryThreadSortBy)Enum.Parse(typeof(GalleryThreadSortBy), userCookie["GalleryThreadSortBy"]);
			}
			set
			{
				userCookie["GalleryThreadSortBy"] = value.ToString();
				WriteCookie();
			}
		}

		public SortOrder ThreadSortOrder
		{
			get
			{
				if(userCookie["GalleryThreadSortOrder"] == null)
					return Galleries.GetGallery(appKey).ThreadSortOrder;
				else
					return (SortOrder)Enum.Parse(typeof(SortOrder), userCookie["GalleryThreadSortOrder"]);
			}
			set
			{
				userCookie["GalleryThreadSortOrder"] = value.ToString();
				WriteCookie();
			}
		}

		public PostCategorySortBy CategoriesSortBy
		{
			get { return (PostCategorySortBy)Enum.Parse(typeof(PostCategorySortBy), userCookie["GalleryCategoriesSortBy"]); }
			set
			{
				userCookie["GalleryCategoriesSortBy"] = value.ToString();
				WriteCookie();
			}
		}

	}
}
