Beispiel #1
0
        /// <summary>
        /// Maps photo DTO to photo view model.
        /// </summary>
        public static PhotoViewModel Map(PhotoDTO item)
        {
            if (item == null)
            {
                return(null);
            }

            return(new PhotoViewModel
            {
                Id = item.Id,
                Path = item.Path,
                Filter = item.Filter,
                Description = item.Description,
                Date = item.Date.ToString("MMMM dd, yyyy"),
                Owner = UsersMapper.Map(item.Owner),
                CountViews = item.CountViews,

                Liked = item.Liked,
                Bookmarked = item.Bookmarked,

                Manufacturer = string.IsNullOrEmpty(item.Manufacturer) ? "Unknown" : item.Manufacturer,
                Model = string.IsNullOrEmpty(item.Model) ? "Unknown" : item.Model,
                Iso = item.Iso != null?item.Iso.ToString() : "Unknown",
                          Exposure = item.Exposure != null ? $"{string.Format("{0:0.00000}", item.Exposure)} sec" : "Unknown",
                          Aperture = item.Aperture != null ? $"f/{item.Aperture.ToString()}" : "Unknown",
                          FocalLength = item.FocalLength != null ? $"{item.FocalLength.ToString()}mm" : "Unknown",

                          Likes = LikesMapper.MapRange(item.Likes),
                          Comments = CommentsMapper.MapRange(item.Comments),
                          Tags = TagsMapper.MapRange(item.Tags)
            });
        }
Beispiel #2
0
        /// <summary>
        /// Maps user details DTOs to user details view models.
        /// </summary>
        public static List <UserDetailsViewModel> MapRange(IEnumerable <UserDetailsDTO> items)
        {
            if (items == null)
            {
                return(null);
            }

            var users = new List <UserDetailsViewModel>();

            foreach (var item in items)
            {
                users.Add(new UserDetailsViewModel
                {
                    RealName       = item.RealName,
                    UserName       = item.UserName,
                    Avatar         = item.Avatar != null ? $"/data/avatars/{item.UserName}/{item.Avatar}" : string.IsNullOrEmpty(item.Gender) || item.Gender == "Male" ? "/images/defaults/def-male-logo.png" : "/images/defaults/def-female-logo.png",
                    About          = item.About != null ? item.About : string.Empty,
                    Date           = item.Date.ToString("MMMM dd, yyyy"),
                    Confirmed      = item.Confirmed,
                    Followed       = item.Followed,
                    Gender         = item.Gender,
                    WebSite        = item.WebSite,
                    Blocked        = item.Blocked,
                    PrivateAccount = item.PrivateAccount,
                    IBlocked       = item.IBlocked,
                    Followings     = UsersMapper.MapRange(item.Followings),
                    Followers      = UsersMapper.MapRange(item.Followers),
                    Mutuals        = item.Mutuals != null ? UsersMapper.MapRange(item.Mutuals) : null
                });
            }

            return(users);
        }
Beispiel #3
0
        /// <summary>
        /// Maps like DTO to like view model.
        /// </summary>
        public static LikeViewModel Map(LikeDTO item)
        {
            if (item == null)
            {
                return(null);
            }

            return(new LikeViewModel
            {
                Id = item.Id,
                Date = item.Date.ToString("MMMM dd, yyyy"),
                Owner = UsersMapper.Map(item.Owner)
            });
        }
Beispiel #4
0
        /// <summary>
        /// Maps comment DTO to comment view model.
        /// </summary>
        public static CommentViewModel Map(CommentDTO item)
        {
            if (item == null)
            {
                return(null);
            }

            return(new CommentViewModel
            {
                Id = item.Id,
                Text = item.Text,
                Date = item.Date.ToString("MMMM dd, yyyy"),
                Owner = UsersMapper.Map(item.Owner)
            });
        }
Beispiel #5
0
        /// <summary>
        /// Maps like DTOs to like view models.
        /// </summary>
        public static List <LikeViewModel> MapRange(IEnumerable <LikeDTO> items)
        {
            if (items == null)
            {
                return(null);
            }

            var likes = new List <LikeViewModel>();

            foreach (var item in items)
            {
                likes.Add(new LikeViewModel
                {
                    Id    = item.Id,
                    Date  = item.Date.ToString("MMMM dd, yyyy"),
                    Owner = UsersMapper.Map(item.Owner)
                });
            }

            return(likes);
        }
Beispiel #6
0
        /// <summary>
        /// Maps comment DTOs to comment view models.
        /// </summary>
        public static List <CommentViewModel> MapRange(IEnumerable <CommentDTO> items)
        {
            if (items == null)
            {
                return(null);
            }

            var comments = new List <CommentViewModel>();

            foreach (var item in items)
            {
                comments.Add(new CommentViewModel
                {
                    Id    = item.Id,
                    Text  = item.Text,
                    Date  = item.Date.ToString("MMMM dd, yyyy"),
                    Owner = UsersMapper.Map(item.Owner)
                });
            }

            return(comments);
        }