/// <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) }); }
/// <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) }); }
/// <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) }); }
/// <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); }
/// <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); }