protected override Product ConvertDbObjectToEntityShort(PyramidFinalContext context, Products dbObject)
        {
            var friendlyUrl  = new RouteItemRepository(context).GetFriendlyUrl(dbObject.Id, Common.TypeEntityFromRouteEnum.ProductType);
            var thumbnailImg = new ImageRepository(context).Get(dbObject.Id, (int)Common.TypeImage.Thumbnail);

            var product = new Product()
            {
                TypeStatusProduct = (Common.TypeStatusProduct)dbObject.TypeStatusProduct,
                Id           = dbObject.Id,
                DateChange   = dbObject.DateChange,
                DateCreation = dbObject.DateCreation,
                IsFilled     = dbObject.IsFilled,
                IsPriority   = dbObject.IsPriority,
                IsSEOReady   = dbObject.IsSEOReady,
                Price        = dbObject.Price,
                SeasonOffer  = dbObject.SeasonOffer.HasValue ? dbObject.SeasonOffer.Value : false,
                Title        = dbObject.Title,
                Content      = dbObject.Content,
                TypePrice    = (Common.TypeProductPrice)dbObject.TypePrice,
                ThumbnailImg = thumbnailImg,
                FriendlyUrl  = friendlyUrl
            };

            return(product);
        }
示例#2
0
        protected override Category ConvertDbObjectToEntityShort(PyramidFinalContext context, Categories dbObject)
        {
            var cat = new Category();

            cat.Id    = dbObject.Id;
            cat.Title = dbObject.Title;
            cat.ShowCategoryOnSite = dbObject.ShowCategoryOnSite;
            cat.Thumbnail          = new ImageRepository(context).GetFromCategory(dbObject.Id, (int)Common.TypeImage.Thumbnail);
            var friendlyUrl = new RouteItemRepository(context).GetFriendlyUrl(dbObject.Id, Common.TypeEntityFromRouteEnum.CategoryType);

            cat.FriendlyUrl = friendlyUrl;

            return(cat);
        }
        public override Page ConvertDbObjectToEntity(PyramidFinalContext context, Pages dbObject)
        {
            var seo      = new SeoRepository(context).Get(dbObject.SeoId.HasValue?dbObject.SeoId.Value:0);
            var friendly = new RouteItemRepository(context).GetFriendlyUrl(dbObject.Id, Common.TypeEntityFromRouteEnum.PageType);
            var page     = new Page()
            {
                Content = dbObject.Content,
                Title   = dbObject.Title,
                Id      = dbObject.Id,
                SeoId   = dbObject.SeoId,
                Seo     = seo
            };

            page.FriendlyUrl = friendly;
            return(page);
        }
示例#4
0
        public override Category ConvertDbObjectToEntity(PyramidFinalContext context, Categories dbObject)
        {
            var seo      = new SeoRepository(context).Get(dbObject.SeoId.HasValue ? dbObject.SeoId.Value : 0);
            var products = new ProductRepository(context).Get(new SearchParamsProduct()
            {
                CategoryId = dbObject.Id, IsSearchOnlyPublicProduct = true
            });
            var friendlyUrl = new RouteItemRepository(context).GetFriendlyUrl(dbObject.Id, Common.TypeEntityFromRouteEnum.CategoryType);
            var cat         = new Category();

            cat.FriendlyUrl = friendlyUrl;
            cat.Filters     = dbObject.Filters.Select(s => new Pyramid.Entity.Filter()
            {
                Id         = s.Id,
                Title      = s.Title,
                EnumValues = s.EnumValues.Select(e => new Pyramid.Entity.EnumValue()
                {
                    Id        = e.Id,
                    Key       = e.Key,
                    TypeValue = (Common.TypeFromEnumValue)e.TypeValue
                }).ToList(),
            }).ToList();


            cat.Products = products.Objects.ToList();

            cat.Id    = dbObject.Id;
            cat.Title = dbObject.Title;


            cat.Thumbnail = new ImageRepository(context).GetFromCategory(dbObject.Id, (int)Common.TypeImage.Thumbnail);

            cat.OneCId             = dbObject.OneCId;
            cat.ParentId           = dbObject.ParentId;
            cat.Content            = dbObject.Content;
            cat.ShowCategoryOnSite = dbObject.ShowCategoryOnSite;
            if (dbObject.Seo != null)
            {
                cat.Seo = new Entity.Seo()
                {
                    Alias           = dbObject.Seo.Alias,
                    Id              = dbObject.Seo.Id,
                    MetaDescription = dbObject.Seo.MetaDescription,
                    MetaKeywords    = dbObject.Seo.MetaKeywords,
                    MetaTitle       = dbObject.Seo.MetaTitle
                };
            }

            if (dbObject.Recommendations != null)
            {
                cat.Recommendations = dbObject.Recommendations.Select(s => new Recommendation()
                {
                    ShortContent = s.ShortContent,
                    Title        = s.Title,
                    Id           = s.Id,
                    Image        = ConvertImageToEntity.Convert(s.Images.FirstOrDefault()),
                    FriendlyUrl  = new RouteItemRepository(context).GetFriendlyUrl(s.Id, Common.TypeEntityFromRouteEnum.RecommendationType)
                }).ToList();
            }
            return(cat);
        }