public static Community ToDto(Db.Community community)
        {
            if (community == null) return null;

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

            return new Community
                {
                    Id = community.Id,
                    Name = community.Name,
                    Description = community.Description,
                    Leader = UserMapper.ToDto(community.Leader),
                    IsDeleted = community.IsDeleted,
                    Members = members,
                    Posts = posts,
                    Emblem = emblem,
                    IsPrivate = community.IsPrivate,
                    CreatedBy = community.CreatedBy,
                    CreatedDate = community.CreatedDate,
                    ModifiedBy = community.ModifiedBy,
                    ModifiedDate = community.ModifiedDate
                };
        }
Exemple #2
0
 public static Album ToDto(Db.Album album)
 {
     if (album != null)
     {
         var media = new List<Media>();
         if (album.Media != null)
         {
             media = album.Media.Select(MediaMapper.ToDto).ToList();
         }
         
         return new Album
         {
             AlbumId = album.AlbumId,
             AlbumName = album.AlbumName,
             Media = media,
             User = UserMapper.ToDto(album.User),
             IsUserDefault = album.IsUserDefault,
             CreatedBy = album.CreatedBy,
             CreatedDate = album.CreatedDate,
             ModifiedBy = album.ModifiedBy,
             ModifiedDate = album.ModifiedDate
         };
     }
     return null;
 }
        public static Comment ToDto(Db.Comment comment)
        {
            if (comment != null)
            {
                var commentLikes = comment.CommentLikes != null
                    ? comment.CommentLikes.Select(CommentLikeMapper.ToDto).ToList()
                    : null;
                var comments = comment.Comments != null
                    ? comment.Comments.Select(ToDto).ToList()
                    : null;

                return new Comment
                {
                    Id = comment.CommentId,
                    CommentLikes = commentLikes,
                    CommentLocation = comment.CommentLocation,
                    CommentMessage = comment.CommentMessage,
                    ParentCommentId = comment.ParentCommentId,
                    PostId = comment.PostId,
                    Comments = comments,
                    User = comment.User != null ? UserMapper.ToDto(comment.User) : null,
                    CreatedBy = comment.CreatedBy,
                    CreatedDate = comment.CreatedDate,
                    ModifiedBy = comment.ModifiedBy,
                    ModifiedDate = comment.ModifiedDate
                };
            }
            return null;
        }
 public static EducationType ToDto(Db.EducationType educationType)
 {
     return educationType == null ? null : 
         new EducationType
         {
             EducationTypeId = educationType.EducationTypeId,
             EducationTypeName = educationType.EducationTypeName
         };
 }
 public static ViewCount ToDto(Db.ViewCount viewCount)
 {
     return viewCount == null ? null :
         new ViewCount
         {
             PostId = viewCount.PostId,
             Id = viewCount.Id,
             UserId = viewCount.UserId
         };
 }
Exemple #6
0
 public static Tag ToDto(Db.Tag tag)
 {
     return tag == null ? null :
         new Tag
         {
             TagId = tag.TagId,
             TagName = tag.TagName,
             CreatedBy = tag.CreatedBy,
             CreatedDate = tag.CreatedDate,
             ModifiedBy = tag.ModifiedBy,
             ModifiedDate = tag.ModifiedDate
         };
 }
Exemple #7
0
 public static Hobby ToDto(Db.Hobby hobby)
 {
     return hobby == null ? null : 
         new Hobby
         {
             HobbyId = hobby.HobbyId,
             HobbyName = hobby.HobbyName,
             UserId = hobby.UserId,
             CreatedBy = hobby.CreatedBy,
             CreatedDate = hobby.CreatedDate,
             ModifiedBy = hobby.ModifiedBy,
             ModifiedDate = hobby.ModifiedDate
         };
 }
 public static PostLike ToDto(Db.PostLike postLike)
 {
     return postLike == null ? null :
         new PostLike
         {
             PostId = postLike.PostId,
             PostLikeId = postLike.PostLikeId,
             UserId = postLike.UserId,
             CreatedBy = postLike.CreatedBy,
             CreatedDate = postLike.CreatedDate,
             ModifiedBy = postLike.ModifiedBy,
             ModifiedDate = postLike.ModifiedDate
         };
 }
 public static CommentLike ToDto(Db.CommentLike commentLike)
 {
     return commentLike == null ? null : 
         new CommentLike
         {
             CommentId = commentLike.CommentId,
             CommentLikeId = commentLike.CommentLikeId,
             UserId = commentLike.UserId,
             CreatedBy = commentLike.CreatedBy,
             CreatedDate = commentLike.CreatedDate,
             ModifiedBy = commentLike.ModifiedBy,
             ModifiedDate = commentLike.ModifiedDate
         };
 }
 public static Address ToDto(Db.Address address)
 {
     return address == null ? null :
         new Address
         {
             AddressId = address.AddressId,
             City = address.City,
             Country = address.Country,
             State = address.State,
             StreetAddress = address.StreetAddress,
             Zip = address.Zip,
             UserId = address.UserId
         };
 }
 public static PostContent ToDto(Db.PostContent postContent)
 {
     return postContent == null ? null : 
         new PostContent
         {
             Id = postContent.PostContentId,
             PostId = postContent.PostId,
             Media = postContent.Media == null ? null : MediaMapper.ToDto(postContent.Media),
             PostContentText = postContent.PostContentText,
             PostContentTitle = postContent.PostContentTitle,
             CreatedBy = postContent.CreatedBy,
             CreatedDate = postContent.CreatedDate,
             ModifiedBy = postContent.ModifiedBy,
             ModifiedDate = postContent.ModifiedDate
         };
 }
        public static ChatMessage ToDto(Db.ChatMessage chatMessage)
        {
            if (chatMessage == null) return null;
            if (chatMessage.FromUser == null || chatMessage.ToUser == null) return null;

            return new ChatMessage
            {
                Id = chatMessage.ChatMessageId,
                FromUser = UserMapper.ToDto(chatMessage.FromUser),
                ToUser = UserMapper.ToDto(chatMessage.ToUser),
                Text = chatMessage.Text,
                CreatedBy = chatMessage.CreatedBy,
                CreatedDate = chatMessage.CreatedDate,
                ModifiedBy = chatMessage.ModifiedBy,
                ModifiedDate = chatMessage.ModifiedDate
            };
        }
Exemple #13
0
        public static Post ToDto(Db.Post post)
        {
            if (post == null) return null;

            var postLikes = post.PostLikes != null
                ? post.PostLikes.Select(PostLikeMapper.ToDto).ToList()
                : null;
            var contents = post.PostContents != null
                ? post.PostContents.Select(PostContentMapper.ToDto).ToList()
                : null;
            var comments = post.Comments != null
                ? post.Comments.Select(CommentMapper.ToDto).ToList()
                : null;
            var tags = post.Tags != null
                ? post.Tags.Select(TagMapper.ToDto).ToList()
                : null;
            var viewCounts = post.ViewCounts != null
                ? post.ViewCounts.Select(ViewCountMapper.ToDto).ToList()
                : null;
            var communities = post.Communities != null
                ? post.Communities.Select(CommunityMapper.ToDto).ToList()
                : null;

            return new Post
                   {
                       Id = post.PostId,
                       PostTitle = post.PostTitle,
                       PostMessage = post.PostMessage,
                       PostLikes = postLikes,
                       PostContents = contents,
                       Comments = comments,
                       ViewCounts = viewCounts,
                       Communities = communities,
                       User = post.User != null ? UserMapper.ToDto(post.User) : null,
                       Tags = tags,
                       CreatedBy = post.CreatedBy,
                       CreatedDate = post.CreatedDate,
                       ModifiedBy = post.ModifiedBy,
                       ModifiedDate = post.ModifiedDate
                   };
        }
Exemple #14
0
 public static Media ToDto(Db.Media media)
 {
     return media == null ? null : 
         new Media
         {
             Id = media.MediaId,
             MediaType = media.MediaType,
             AlbumId = media.AlbumId,
             MediaContent = null,
             MediaPath = media.MediaPath,
             MediaUrl = media.MediaUrl,
             ThumbnailUrl = media.ThumbnailUrl,
             ThumbnailPath = media.ThumbnailPath,
             FileName = media.FileName,
             CustomName = media.CustomName,
             CreatedBy = media.CreatedBy,
             CreatedDate = media.CreatedDate,
             ModifiedBy = media.ModifiedBy,
             ModifiedDate = media.ModifiedDate
         };
 }
        public static Education ToDto(Db.Education education)
        {
            if (education == null) return null;

            return new Education
                {
                    City = education.City,
                    Country = education.Country,
                    State = education.State,
                    YearAttended = education.YearAttended,
                    YearGraduated = education.YearGraduated,
                    Course = education.Course,
                    SchoolName = education.SchoolName,
                    EducationType = EducationTypeMapper.ToDto(education.EducationType),
                    EducationId = education.EducationId,
                    UserId = education.UserId,
                    CreatedBy = education.CreatedBy,
                    CreatedDate = education.CreatedDate,
                    ModifiedBy = education.ModifiedBy,
                    ModifiedDate = education.ModifiedDate
                };
        }
Exemple #16
0
        public static User ToDto(Db.User user)
        {
            if (user != null)
            {
                var education = user.Education != null
                    ? user.Education.Select(EducationMapper.ToDto).ToList()
                    : null;
                var hobbies = user.Hobbies != null
                    ? user.Hobbies.Select(HobbyMapper.ToDto).ToList()
                    : null;
                var picture = user.Picture != null
                    ? MediaMapper.ToDto(user.Picture)
                    : null;
                var background = user.Background != null
                   ? MediaMapper.ToDto(user.Background)
                   : null;

                return new User
                {
                    Id = user.UserId,
                    UserName = user.UserName,
                    IdentityId = user.IdentityId,
                    BirthDate = user.BirthDate,
                    FirstName = user.FirstName,
                    LastName = user.LastName,
                    EmailAddress = user.EmailAddress,
                    Address = AddressMapper.ToDto(user.Address),
                    Education = education,
                    Hobbies = hobbies,
                    PictureId = user.PictureId,
                    Picture = picture,
                    BackgroundId = user.BackgroundId,
                    Background = background,
                    IsDeleted = user.IsDeleted
                };
            }
            return null;
        }