private void SetPost(Post post) { if (post == null) { return; } post.Url = cacheManager.Get(CacheConstant.POST_URL_ITEM.FormatInvariant(post.Id), () => { return(urlService.GetUrl(post.Id, nameof(Post))); }); post.Picture = cacheManager.Get(CacheConstant.MEDIA_STORAGE_ITEM.FormatInvariant(post.PictureId), () => { return(mediaStorageService.GetById(post.PictureId)); }); post.Category = cacheManager.Get(CacheConstant.CATEGORY_ITEM.FormatInvariant(post.CategoryId), () => { return(categoryService.GetById(post.CategoryId)); }); post.PostTags = cacheManager.Get(CacheConstant.POST_TAG_ITEM.FormatInvariant(post.Id), () => { return(tagService.GetTagsByPostId(post.Id).ToList()); }); post.User = cacheManager.Get(CacheConstant.USER_ID.FormatInvariant(post.UserId), () => { return(userService.GetById(post.UserId)); }); if (post.User != null) { post.UserName = post.User.UserName; } post.Comments = new List <Comment>(); }
private void SetPortfolio(Portfolio portfolio) { if (portfolio == null) { return; } portfolio.Url = cacheManager.Get(CacheConstant.PORTFOLIO_URL_ITEM.FormatInvariant(portfolio.Id), () => { return(urlService.GetUrl(portfolio.Id, nameof(Portfolio))); }); portfolio.Picture = cacheManager.Get(CacheConstant.MEDIA_STORAGE_ITEM.FormatInvariant(portfolio.PictureId), () => { return(mediaStorageService.GetById(portfolio.PictureId)); }); portfolio.Category = cacheManager.Get(CacheConstant.PORTFOLIO_CATEGORY_ITEM.FormatInvariant(portfolio.CategoryId), () => { return(categoryService.GetById(portfolio.CategoryId)); }); portfolio.User = cacheManager.Get(CacheConstant.USER_ID.FormatInvariant(portfolio.UserId), () => { return(userService.GetById(portfolio.UserId)); }); var pictures = cacheManager.Get(CacheConstant.MEDIA_STORAGE_PORTFOLIO_ITEM_PISTURES.FormatInvariant(portfolio.Id, nameof(Portfolio)), () => { return(mediaStorageService.GetByEntity(portfolio.Id.ToString(), nameof(Portfolio)).ToList()); }); portfolio.Pictures = new List <MediaStorage>(); portfolio.Pictures.Add(portfolio.Picture); portfolio.Pictures.AddRange(pictures); }