using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Hydra.Framework;
using Hydra.Framework.Helpers;
using Hydra.Framework.Conversions;
using DataModel = Hydra.Data.Model;
using DomainModel = Hydra.DomainModel;

namespace Hydra.Domain.Mapping
{
    public class CommunityThreadMapping
        : IEntityMapper<DataModel.CommunityThread, DomainModel.InternalCommunityThread>
    {
        #region Implementation of IEntityMapper
        /// <summary>
        /// Convert Domain Model Entity to Data Model Entity
        /// </summary>
        /// <param name="entity">Domain Model Entity</param>
        /// <returns></returns>
        public DataModel.CommunityThread MapDomainEntityToDataEntity(DomainModel.InternalCommunityThread entity)
        {
            DataModel.CommunityThread item = entity == null
                ? null
                : new DataModel.CommunityThread()
                {
                    ID = entity.ID,
                    Name = entity.Name,
                    Approved = entity.Approved,
                    Author = entity.Author,
                    ForumID = entity.ForumID,
                    IsApproved = entity.IsApproved,
                    IsLocked = entity.IsLocked,
                    IsDeleted = entity.IsDeleted,
                    IsPinned = entity.IsPinned,
                    LastPosted = entity.LastPosted,
                    LastPostID = entity.LastPostID,
                    LastPostUser = entity.LastPostUser,
                    LinkTo = entity.LinkTo,
                    Moderator = entity.Moderator,
                    IsQuestion = entity.IsQuestion,
                    IsResolved = entity.IsResolved,
                    Posted = entity.Posted,
                    ThreadType = entity.ThreadType,
                    TotalPosts = entity.TotalPosts,
                    TotalReads = entity.TotalReads
                };

            return item;
        }

        /// <summary>
        /// Convert Data Model Entity to Domain Model Entity
        /// </summary>
        /// <param name="entity">Data Model Entity</param>
        /// <returns>Domain Model Entity</returns>
        public DomainModel.InternalCommunityThread MapDataEntityToDomainEntity(DataModel.CommunityThread entity)
        {
            return entity == null
                ? null
                : new DomainModel.InternalCommunityThread()
                {
                    ID = entity.ID,
                    Name = entity.Name,
                    Approved = entity.Approved,
                    Author = entity.Author,
                    ForumID = entity.ForumID,
                    IsApproved = entity.IsApproved,
                    IsLocked = entity.IsLocked,
                    IsDeleted = entity.IsDeleted,
                    IsPinned = entity.IsPinned,
                    LastPosted = entity.LastPosted,
                    LastPostID = entity.LastPostID,
                    LastPostUser = entity.LastPostUser,
                    LinkTo = entity.LinkTo,
                    Moderator = entity.Moderator,
                    IsQuestion = entity.IsQuestion,
                    IsResolved = entity.IsResolved,
                    Posted = entity.Posted,
                    ThreadType = entity.ThreadType,
                    TotalPosts = entity.TotalPosts,
                    TotalReads = entity.TotalReads
                };
        }
        #endregion
    }
}
