コード例 #1
0
 public CommentApiController(ICustomerCommentService customerCommentService,
                             IWorkContext workContext,
                             IDateTimeHelper dateTimeHelper,
                             ICustomerService customerService,
                             ICustomerLikeService customerLikeService,
                             IPictureService pictureService, MediaSettings mediaSettings)
 {
     _customerCommentService = customerCommentService;
     _workContext            = workContext;
     _dateTimeHelper         = dateTimeHelper;
     _customerService        = customerService;
     _customerLikeService    = customerLikeService;
     _pictureService         = pictureService;
     _mediaSettings          = mediaSettings;
 }
コード例 #2
0
 public SkillController(ISkillService skillService, ICustomerService userService, IMediaService mediaService, MediaSettings mediaSettings, IUserSkillService userSkillService, ICustomerFollowService followService, ICustomerLikeService likeService, ICustomerCommentService commentService, IWorkContext workContext, ICustomerProfileService customerProfileService, ICustomerProfileViewService customerProfileViewService, IPictureService pictureService, IUrlRecordService urlRecordService, IStoreContext storeContext, IWebHelper webHelper)
 {
     _skillService               = skillService;
     _userService                = userService;
     _mediaService               = mediaService;
     _mediaSettings              = mediaSettings;
     _userSkillService           = userSkillService;
     _followService              = followService;
     _likeService                = likeService;
     _commentService             = commentService;
     _workContext                = workContext;
     _customerProfileService     = customerProfileService;
     _customerProfileViewService = customerProfileViewService;
     _pictureService             = pictureService;
     _urlRecordService           = urlRecordService;
     _storeContext               = storeContext;
     _webHelper = webHelper;
 }
コード例 #3
0
 public MediaApiController(MediaService mediaService, MediaSettings mediaSettings, IMobSocialVideoProcessor videoProcessor, ICustomerService userService, ICustomerCommentService commentService, ICustomerLikeService likeService, IEntityMediaService entityMediaService, IWorkContext workContext, IStoreContext storeContext, ICustomerProfileService customerProfileService, ICustomerProfileViewService customerProfileViewService, ICustomerLikeService customerLikeService, ICustomerFollowService customerFollowService, ICustomerCommentService customerCommentService, IFriendService friendService, IPictureService pictureService, IWebHelper webHelper)
 {
     _mediaService               = mediaService;
     _mediaSettings              = mediaSettings;
     _videoProcessor             = videoProcessor;
     _userService                = userService;
     _commentService             = commentService;
     _likeService                = likeService;
     _entityMediaService         = entityMediaService;
     _workContext                = workContext;
     _storeContext               = storeContext;
     _customerProfileService     = customerProfileService;
     _customerProfileViewService = customerProfileViewService;
     _customerLikeService        = customerLikeService;
     _customerFollowService      = customerFollowService;
     _customerCommentService     = customerCommentService;
     _friendService              = friendService;
     _pictureService             = pictureService;
     _webHelper = webHelper;
 }
コード例 #4
0
 public TimelineApiController(ITimelineService timelineService,
                              IWorkContext workContext,
                              ICustomerFollowService customerFollowService,
                              ICustomerService customerService,
                              IPictureService pictureService,
                              MediaSettings mediaSettings,
                              IDateTimeHelper dateTimeHelper,
                              mobSocialSettings mobSocialSettings,
                              IVideoBattleService videoBattleService,
                              ICustomerLikeService customerLikeService,
                              ICustomerCommentService customerCommentService)
 {
     _timelineService        = timelineService;
     _workContext            = workContext;
     _customerFollowService  = customerFollowService;
     _customerService        = customerService;
     _pictureService         = pictureService;
     _mediaSettings          = mediaSettings;
     _dateTimeHelper         = dateTimeHelper;
     _mobSocialSettings      = mobSocialSettings;
     _videoBattleService     = videoBattleService;
     _customerLikeService    = customerLikeService;
     _customerCommentService = customerCommentService;
 }
コード例 #5
0
        public static MediaReponseModel ToModel <T>(this Media media, int entityId,
                                                    IMediaService mediaService,
                                                    MediaSettings mediaSettings,
                                                    IWorkContext workContext,
                                                    IStoreContext storeContext,
                                                    ICustomerService userService,
                                                    ICustomerProfileService customerProfileService,
                                                    ICustomerProfileViewService customerProfileViewService,
                                                    IPictureService pictureService,
                                                    UrlHelper urlHelper,
                                                    IWebHelper webHelper,
                                                    IFriendService friendService           = null,
                                                    ICustomerCommentService commentService = null,
                                                    ICustomerLikeService likeService       = null,
                                                    bool withUserInfo             = true,
                                                    bool withSocialInfo           = false,
                                                    bool withNextAndPreviousMedia = false,
                                                    bool avoidMediaTypeForNextAndPreviousMedia = false) where T : BaseEntity
        {
            var storeUrl = webHelper.GetStoreLocation();
            var model    = new MediaReponseModel()
            {
                Id             = media.Id,
                MediaType      = media.MediaType,
                Url            = media.MediaType == MediaType.Image ? mediaService.GetPictureUrl(media) : mediaService.GetVideoUrl(media),
                MimeType       = media.MimeType,
                DateCreatedUtc = media.DateCreated,
                ThumbnailUrl   = media.MediaType == MediaType.Image ? mediaService.GetPictureUrl(media) : media.ThumbnailPath.Replace("~", storeUrl)
            };

            if (withUserInfo && userService != null)
            {
                var user = userService.GetCustomerById(media.UserId);
                if (user != null)
                {
                    var dateTimeHelper = EngineContext.Current.Resolve <IDateTimeHelper>();
                    model.CreatedBy        = user.ToPublicModel(workContext, customerProfileViewService, customerProfileService, pictureService, mediaSettings, urlHelper);
                    model.DateCreatedLocal = dateTimeHelper.ConvertToUserTime(media.DateCreated, DateTimeKind.Utc);
                }
            }
            if (withSocialInfo)
            {
                if (likeService != null)
                {
                    model.TotalLikes = likeService.GetLikeCount <Media>(media.Id);
                    model.LikeStatus =
                        likeService.GetCustomerLike <Media>(workContext.CurrentCustomer.Id, media.Id) != null
                            ? 1
                            : 0;
                }

                if (commentService != null)
                {
                    model.TotalComments = commentService.GetCommentsCount(media.Id, typeof(Media).Name);
                    model.CanComment    = true; //todo: perform check if comments are enabled or user has permission to comment
                }
            }

            if (withNextAndPreviousMedia)
            {
                MediaType?mediaType = null;
                if (!avoidMediaTypeForNextAndPreviousMedia)
                {
                    mediaType = media.MediaType;
                }
                var allMedia   = mediaService.GetEntityMedia <T>(entityId, mediaType, 1, int.MaxValue).ToList();
                var mediaIndex = allMedia.FindIndex(x => x.Id == media.Id);

                model.PreviousMediaId = mediaIndex <= 0 ? 0 : allMedia[mediaIndex - 1].Id;
                model.NextMediaId     = mediaIndex < 0 || mediaIndex == allMedia.Count - 1 ? 0 : allMedia[mediaIndex + 1].Id;
            }

            model.FullyLoaded = withSocialInfo && withNextAndPreviousMedia;
            return(model);

            ;
        }
コード例 #6
0
        public static SkillWithUsersModel ToSkillWithUsersModel(this Skill skill, IWorkContext workContext, IStoreContext storeContext, ICustomerService customerService, IUserSkillService userSkillService, IMediaService mediaService,
                                                                MediaSettings mediaSettings, ICustomerFollowService followService, ICustomerLikeService likeService, ICustomerCommentService commentService, ICustomerProfileService customerProfileService, ICustomerProfileViewService customerProfileViewService, IPictureService pictureService, UrlHelper urlHelper, IWebHelper webHelper)
        {
            var currentUser = workContext.CurrentCustomer;
            var model       = new SkillWithUsersModel()
            {
                Skill = skill.ToModel(workContext),
                FeaturedMediaImageUrl = skill.FeaturedImageId > 0 ? mediaService.GetPictureUrl(skill.FeaturedImageId) : ""
            };

            var perPage = 15;
            //by default we'll send data for 15 users. rest can be queried with paginated request
            //todo: make this thing configurable to set number of users to return with this response
            var userSkills = userSkillService.Get(x => x.SkillId == skill.Id).ToList();

            model.UserSkills =
                userSkills.OrderBy(x => x.Id).Take(perPage).Select(
                    x =>
                    x.ToModel(mediaService, mediaSettings, workContext, storeContext, customerService,
                              customerProfileViewService, customerProfileService, pictureService, urlHelper, webHelper, false, true, true, false)).ToList();

            model.CurrentPage   = 1;
            model.UsersPerPage  = perPage;
            model.TotalUsers    = userSkillService.Count(x => x.SkillId == skill.Id);
            model.FollowerCount = followService.GetFollowerCount <Skill>(skill.Id);

            //does this user follow this skill?
            var userFollow = followService.GetCustomerFollow <Skill>(currentUser.Id, skill.Id);

            model.CanFollow     = true;
            model.FollowStatus  = userFollow == null ? 0 : 1;
            model.HasSkill      = userSkills.Any(x => x.UserId == currentUser.Id);
            model.TotalComments = commentService.GetCommentsCount(skill.Id, "skill");
            model.LikeStatus    = likeService.GetCustomerLike <Skill>(currentUser.Id, skill.Id) == null ? 0 : 1;
            model.TotalLikes    = likeService.GetLikeCount <Skill>(skill.Id);
            return(model);
        }