Click here to Skip to main content
15,897,704 members
Articles / Web Development / ASP.NET

Open Source Extensible Enterprise n-tier Application Framework with Multilayered Architecture

Rate me:
Please Sign up or sign in to vote.
4.67/5 (2 votes)
3 Dec 2010MIT3 min read 37.1K   770   41  
Xenta architecture overview
using SiberTek.Xenta.Data.Entities;
using SiberTek.Xenta.Data.Entities.Collections;
using SiberTek.Xenta.Entities;
using SiberTek.Xenta.Entities.Collections;
using SiberTek.Xenta.Enums;

namespace SiberTek.Xenta.Utils
{
    /// <summary>
    /// Contains methods to convert data entities to business logic entities
    /// </summary>
    internal static class DataMapper
    {
        #region Methods
        public static ForumInfo Map(ForumData data)
        {
            ForumInfo entity = null;

            if(data != null)
            {
                entity = new ForumInfo();

                entity.ForumID = data.ForumID;
                entity.ParentForumID = data.ParentForumID;
                entity.Title = data.Title;
                entity.Description = data.Description;
                entity.TopicCount = data.TopicCount;
                entity.PostCount = data.PostCount;
                entity.DisplayOrder = data.DisplayOrder;
                entity.IsActive = data.IsActive;
                entity.CreatedOn = data.CreatedOn;
                entity.UpdatedOn = data.UpdatedOn;
            }

            return entity;
        }

        public static ForumInfoCollection Map(ForumDataCollection dataCollection)
        {
            ForumInfoCollection entityCollection = new ForumInfoCollection();

            if(dataCollection != null)
            {
                foreach(ForumData data in dataCollection)
                {
                    entityCollection.Add(Map(data));
                }
            }

            return entityCollection;
        }

        public static ForumPostInfo Map(ForumPostData data)
        {
            ForumPostInfo entity = null;

            if(data != null)
            {
                entity = new ForumPostInfo();

                entity.PostID = data.PostID;
                entity.ParentPostID = data.ParentPostID;
                entity.TopicID = data.TopicID;
                entity.AuthorID = data.AuthorID;
                entity.Title = data.Title;
                entity.Text = data.Text;
                entity.IsActive = data.IsActive;
                entity.CreatedOn = data.CreatedOn;
                entity.UpdatedOn = data.UpdatedOn;
            }

            return entity;
        }

        public static ForumPostInfoCollection Map(ForumPostDataCollection dataCollection)
        {
            ForumPostInfoCollection entityCollection = new ForumPostInfoCollection();

            if(dataCollection != null)
            {
                foreach(ForumPostData data in dataCollection)
                {
                    entityCollection.Add(Map(data));
                }
            }

            return entityCollection;
        }

        public static ForumPrivateMessageInfo Map(ForumPrivateMessageData data)
        {
            ForumPrivateMessageInfo entity = null;

            if(data != null)
            {
                entity = new ForumPrivateMessageInfo();

                entity.PrivateMessageID = data.PrivateMessageID;
                entity.AuthorID = data.AuthorID;
                entity.RecipientID = data.RecipientID;
                entity.Subject = data.Subject;
                entity.Text = data.Text;
                entity.IsRead = data.IsRead;
                entity.IsDeletedByAuthor = data.IsDeletedByAuthor;
                entity.IsDeletedByRecipient = data.IsDeletedByRecipient;
                entity.IsActive = data.IsActive;
                entity.CreatedOn = data.CreatedOn;
                entity.UpdatedOn = data.UpdatedOn;
            }

            return entity;
        }

        public static ForumPrivateMessageInfoCollection Map(ForumPrivateMessageDataCollection dataCollection)
        {
            ForumPrivateMessageInfoCollection entityCollection = new ForumPrivateMessageInfoCollection();

            if(dataCollection != null)
            {
                foreach(ForumPrivateMessageData data in dataCollection)
                {
                    entityCollection.Add(Map(data));
                }
            }

            return entityCollection;
        }

        public static ForumProfileInfo Map(ForumProfileData data)
        {
            ForumProfileInfo entity = null;

            if(data != null)
            {
                entity = new ForumProfileInfo();
                entity.ProfileID = data.ProfileID;
                entity.UserID = data.UserID;
                entity.LastPostID = data.LastPostID;
                entity.PostCount = data.PostCount;
                entity.RankID = data.RankID;
                entity.CreatedOn = data.CreatedOn;
                entity.UpdatedOn = data.UpdatedOn;
            }

            return entity;
        }

        public static ForumProfileInfoCollection Map(ForumProfileDataCollection dataCollection)
        {
            ForumProfileInfoCollection entityCollection = new ForumProfileInfoCollection();

            if(dataCollection != null)
            {
                foreach(ForumProfileData data in dataCollection)
                {
                    entityCollection.Add(Map(data));
                }
            }

            return entityCollection;
        }

        public static ForumRankInfo Map(ForumRankData data)
        {
            ForumRankInfo entity = null;

            if(data != null)
            {
                entity = new ForumRankInfo();

                entity.RankID = data.RankID;
                entity.Name = data.Name;
                entity.PostCountThreshold = data.PostCountThreshold;
                entity.IsActive = data.IsActive;
                entity.CreatedOn = data.CreatedOn;
                entity.UpdatedOn = data.UpdatedOn;
            }

            return entity;
        }

        public static ForumRankInfoCollection Map(ForumRankDataCollection dataCollection)
        {
            ForumRankInfoCollection entityCollection = new ForumRankInfoCollection();

            if(dataCollection != null)
            {
                foreach(ForumRankData data in dataCollection)
                {
                    entityCollection.Add(Map(data));
                }
            }

            return entityCollection;
        }

        public static ForumTopicInfo Map(ForumTopicData data)
        {
            ForumTopicInfo entity = null;

            if(data != null)
            {
                entity = new ForumTopicInfo();

                entity.TopicID = data.TopicID;
                entity.ForumID = data.ForumID;
                entity.AuthorID = data.AuthorID;
                entity.Title = data.Title;
                entity.Description = data.Description;
                entity.LastPostID = data.LastPostID;
                entity.PostCount = data.PostCount;
                entity.Type = data.Type;
                entity.IsActive = data.IsActive;
                entity.CreatedOn = data.CreatedOn;
                entity.UpdatedOn = data.UpdatedOn;
            }

            return entity;
        }

        public static ForumTopicInfoCollection Map(ForumTopicDataCollection dataCollection)
        {
            ForumTopicInfoCollection entityCollection = new ForumTopicInfoCollection();

            if(dataCollection != null)
            {
                foreach(ForumTopicData data in dataCollection)
                {
                    entityCollection.Add(Map(data));
                }
            }

            return entityCollection;
        }

        public static ForumBanInfo Map(ForumBanData data)
        {
            ForumBanInfo entity = null;

            if(data != null)
            {
                entity = new ForumBanInfo();

                entity.BanID = data.BanID;
                entity.UserID = data.UserID;
                entity.Description = data.Description;
                entity.CreatedOn = data.CreatedOn;
                entity.ExpiredOn = data.ExpiredOn;
                entity.UpdatedOn = data.UpdatedOn;
            }

            return entity;
        }

        public static ForumBanInfoCollection Map(ForumBanDataCollection dataCollection)
        {
            ForumBanInfoCollection entityCollection = new ForumBanInfoCollection();

            if(dataCollection != null)
            {
                foreach(ForumBanData data in dataCollection)
                {
                    entityCollection.Add(Map(data));
                }
            }

            return entityCollection;
        }

        public static ForumSubscriptionInfo Map(ForumSubscriptionData data)
        {
            ForumSubscriptionInfo entity = null;

            if(data != null)
            {
                entity = new ForumSubscriptionInfo();

                entity.SubscriptionID = data.SubscriptionID;
                entity.Type = data.Type;
                entity.ForumEntityID = data.ForumEntityID;
                entity.UserID = data.UserID;
                entity.CreatedOn = data.CreatedOn;
                entity.UpdatedOn = data.UpdatedOn;
            }

            return entity;
        }

        public static ForumSubscriptionInfoCollection Map(ForumSubscriptionDataCollection dataCollection)
        {
            ForumSubscriptionInfoCollection entityCollection = new ForumSubscriptionInfoCollection();

            if(dataCollection != null)
            {
                foreach(ForumSubscriptionData data in dataCollection)
                {
                    entityCollection.Add(Map(data));
                }
            }

            return entityCollection;
        }
        #endregion
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The MIT License


Written By
Russian Federation Russian Federation
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions