﻿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
{
    /// <summary>
    /// Widget Instance Entity Mapper
    /// </summary>
    public class WidgetInstanceMapping
        : IEntityMapper<DataModel.WidgetInstance, DomainModel.InternalWidgetInstance>
    {
        #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.WidgetInstance MapDomainEntityToDataEntity(DomainModel.InternalWidgetInstance entity)
        {
            DataModel.WidgetInstance item = entity == null
                ? null
                : new DataModel.WidgetInstance()
                {
                    ID = entity.ID,
                    WidgetExternalID = entity.WidgetExternalID,
                    DescriptorID = entity.WidgetDescriptorID,
                    PageID = entity.PageID,
                    Action = entity.Action,
                    Area = entity.Area,
                    BodyCssText = entity.BodyCssText,
                    ContentUrl = entity.ContentUrl,
                    Controller = entity.Controller,
                    CssText = entity.CssText,
                    Data = entity.Data,
                    HeaderCssText = entity.HeaderCssText,
                    IconUrl = entity.IconUrl,
                    IsClosable = entity.IsClosable,
                    IsDeletable = entity.IsDeletable,
                    IsExpanded = entity.IsExpanded,
                    IsStatic = entity.IsStatic,
                    Pos = entity.Pos,
                    Scope = entity.Scope,
                    ShowBorder = entity.ShowBorder,
                    ShowHeader = entity.ShowHeader,
                    Title = entity.Title,
                    TitleLinkUrl = entity.TitleLinkUrl,
                    ZoneID = entity.ZoneID
                };

            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.InternalWidgetInstance MapDataEntityToDomainEntity(DataModel.WidgetInstance entity)
        {
            return entity == null
                ? null
                : new DomainModel.InternalWidgetInstance()
                {
                    ID = entity.ID,
                    WidgetExternalID = entity.WidgetExternalID,
                    WidgetDescriptorID = entity.DescriptorID,
                    PageID = entity.PageID,
                    Action = entity.Action,
                    Area = entity.Area,
                    BodyCssText = entity.BodyCssText,
                    ContentUrl = entity.ContentUrl,
                    Controller = entity.Controller,
                    CssText = entity.CssText,
                    Data = entity.Data,
                    HeaderCssText = entity.HeaderCssText,
                    IconUrl = entity.IconUrl,
                    IsClosable = entity.IsClosable,
                    IsDeletable = entity.IsDeletable,
                    IsExpanded = entity.IsExpanded,
                    IsStatic = entity.IsStatic,
                    Pos = entity.Pos,
                    Scope = entity.Scope,
                    ShowBorder = entity.ShowBorder,
                    ShowHeader = entity.ShowHeader,
                    Title = entity.Title,
                    TitleLinkUrl = entity.TitleLinkUrl,
                    ZoneID = entity.ZoneID
                };
        }
        #endregion
    }
}
