Exemplo n.º 1
0
        public static CustomerProfilePublicModel ToPublicModel(this Customer customer,
                                                               IWorkContext workContext,
                                                               ICustomerProfileViewService customerProfileViewService,
                                                               ICustomerProfileService customerProfileService,
                                                               IPictureService pictureService,
                                                               MediaSettings mediaSettings,
                                                               UrlHelper url)
        {
            var customerSeName = customer.GetSeName(workContext.WorkingLanguage.Id, true, false);
            var model          = new CustomerProfilePublicModel()
            {
                CustomerId   = customer.Id,
                ViewCount    = customerProfileViewService.GetViewCount(customer.Id),
                FriendCount  = customerProfileService.GetFriendCount(customer.Id),
                CustomerName = customer.GetFullName(),
                SeName       = customerSeName,
                ProfileUrl   = url.RouteUrl("CustomerProfileUrl", new RouteValueDictionary()
                {
                    { "SeName", customerSeName }
                }),
                ProfileImageUrl =
                    pictureService.GetPictureUrl(
                        customer.GetAttribute <int>(SystemCustomerAttributeNames.AvatarPictureId),
                        mediaSettings.AvatarPictureSize, true),
                CoverImageUrl =
                    pictureService.GetPictureUrl(
                        customer.GetAttribute <int>(AdditionalCustomerAttributeNames.CoverImageId))
            };

            return(model);
        }