public static UserSkillModel ToModel(this UserSkill userSkill, IMediaService mediaService, MediaSettings mediaSettings, GeneralSettings generalSettings, bool onlySkillData = false, bool firstMediaOnly = false, bool withNextAndPreviousMedia = false, bool withSocialInfo = false) { var entityMedias = mediaService.GetEntityMedia <UserSkill>(userSkill.Id, null, count: int.MaxValue).ToList(); var model = new UserSkillModel() { DisplayOrder = userSkill.Skill.DisplayOrder, Name = userSkill.Skill.Name, UserSkillId = userSkill.Id, Id = userSkill.SkillId, User = onlySkillData ? null : userSkill.User.ToModel(mediaService, mediaSettings), Media = entityMedias.Take(firstMediaOnly ? 1 : 15) .ToList() .Select( x => x.ToModel <UserSkill>(userSkill.Id, mediaService, mediaSettings, generalSettings, withNextAndPreviousMedia: withNextAndPreviousMedia, withSocialInfo: withSocialInfo, avoidMediaTypeForNextAndPreviousMedia: true)) .ToList(), TotalMediaCount = entityMedias.Count, TotalPictureCount = entityMedias.Count(x => x.MediaType == MediaType.Image), TotalVideoCount = entityMedias.Count(x => x.MediaType == MediaType.Video), ExternalUrl = userSkill.ExternalUrl, Description = userSkill.Description, SeName = userSkill.Skill.GetPermalink().ToString() }; return(model); }
public static UserSkillModel ToModel(this UserSkill userSkill, IMediaService mediaService, MediaSettings mediaSettings, IWorkContext workContext, IStoreContext storeContext, ICustomerService customerService, ICustomerProfileViewService customerProfileViewService, ICustomerProfileService customerProfileService, IPictureService pictureService, UrlHelper url, IWebHelper webHelper, bool onlySkillData = false, bool firstMediaOnly = false, bool withNextAndPreviousMedia = false, bool withSocialInfo = false) { var entityMedias = mediaService.GetEntityMedia <UserSkill>(userSkill.Id, null, count: int.MaxValue).ToList(); var customer = onlySkillData ? null : customerService.GetCustomerById(userSkill.UserId); var model = new UserSkillModel() { DisplayOrder = userSkill.Skill.DisplayOrder, SkillName = userSkill.Skill.Name, UserSkillId = userSkill.Id, Id = userSkill.SkillId, User = onlySkillData ? null : customer.ToPublicModel(workContext, customerProfileViewService, customerProfileService, pictureService, mediaSettings, url), Media = entityMedias.Take(firstMediaOnly ? 1 : 15) .ToList() .Select( x => x.ToModel <UserSkill>(userSkill.Id, mediaService, mediaSettings, workContext, storeContext, customerService, customerProfileService, customerProfileViewService, pictureService, url, webHelper)) .ToList(), TotalMediaCount = entityMedias.Count, TotalPictureCount = entityMedias.Count(x => x.MediaType == MediaType.Image), TotalVideoCount = entityMedias.Count(x => x.MediaType == MediaType.Video), ExternalUrl = userSkill.ExternalUrl, Description = userSkill.Description, SeName = userSkill.Skill.GetSeName(workContext.WorkingLanguage.Id, true, false) }; return(model); }