Blog.Logic.ObjectMapper.CommunityMapper.ToEntity C# (CSharp) 메소드

ToEntity() 공개 정적인 메소드

public static ToEntity ( Community community ) : Community
community Community
리턴 Blog.DataAccess.Database.Entities.Objects.Community
        public static Db.Community ToEntity(Community community)
        {
            if (community == null) return null;

            var members = community.Members != null
                ? community.Members.Select(UserMapper.ToEntity).ToList()
                : null;
            var posts = community.Posts != null
                ? community.Posts.Select(PostMapper.ToEntity).ToList()
                : null;
            var emblem = community.Emblem != null
                    ? (int?)community.Emblem.Id
                    : null;

            return new Db.Community
                {
                    Id = community.Id,
                    Name = community.Name,
                    Description = community.Description,
                    Members = members,
                    Posts = posts,
                    IsDeleted = community.IsDeleted,
                    LeaderUserId = community.Leader != null ? community.Leader.Id : 0,
                    Leader = null,
                    EmblemId = emblem,
                    IsPrivate = community.IsPrivate,
                    CreatedBy = community.CreatedBy,
                    CreatedDate = community.CreatedDate,
                    ModifiedBy = community.ModifiedBy,
                    ModifiedDate = community.ModifiedDate
                };
        }
    }
CommunityMapper