public override Product ConvertDbObjectToEntity(PyramidFinalContext context, Products dbObject) { var seo = new SeoRepository(context).Get(dbObject.SeoId.HasValue? dbObject.SeoId.Value:0); var categories = new CategoryRepository(context).Get(new SearchParamsCategory() { ProductId = dbObject.Id }); var enumValues = new EnumValueRepository(context).Get(new SearchParamsEnumValue() { ProductId = dbObject.Id }); var images = new ImageRepository(context).Get(new SearchParamsImage() { ProductId = dbObject.Id, TypeImage = (int)Common.TypeImage.GalleryItem }); var thumbnailImg = new ImageRepository(context).Get(dbObject.Id, (int)Common.TypeImage.Thumbnail); //var friedlyUrl = new RouteItemRepository(context).GetFriendlyUrl(dbObject.Id, Common.TypeEntityFromRouteEnum.ProductType); var product = new Product() { Seo = seo, SeoId = dbObject.SeoId, TypeStatusProduct = (Common.TypeStatusProduct)dbObject.TypeStatusProduct, Id = dbObject.Id, DateChange = dbObject.DateChange, DateCreation = dbObject.DateCreation, IsFilled = dbObject.IsFilled, IsPriority = dbObject.IsPriority, IsSEOReady = dbObject.IsSEOReady, PopularCount = dbObject.PopularCount.HasValue ? dbObject.PopularCount.Value : 0, OneCId = dbObject.OneCId, Price = dbObject.Price, SeasonOffer = dbObject.SeasonOffer.HasValue ? dbObject.SeasonOffer.Value:false, Title = dbObject.Title, TypePrice = (Common.TypeProductPrice)dbObject.TypePrice, Content = dbObject.Content, IsNotUnloading1C = dbObject.IsNotUnloading1C, Categories = categories.Objects, EnumValues = enumValues.Objects, Images = images.Objects, ProductValues = dbObject.ProductValues.Select(i => new ProductValue { Id = i.Id, Key = i.Key, ProductId = i.ProductId, Value = i.Value }).ToList(), Reviews = dbObject.Reviews.Where(w => w.IsApproved).Select(i => new Pyramid.Entity.Review { Content = i.Content, DateCreation = i.DateCreation, Name = i.Name, Rating = i.Rating }).ToList(), ThumbnailImg = thumbnailImg }; return(product); }
protected override FAQ ConvertDbObjectToEntityShort(PyramidFinalContext context, Faq dbObject) { var seo = new SeoRepository(context).Get(dbObject.SeoId.HasValue ? dbObject.SeoId.Value : 0); var faq = new FAQ() { Id = dbObject.Id, Title = dbObject.Title, FriendlyUrl = new RouteItemRepository(context).GetFriendlyUrl(dbObject.Id, Common.TypeEntityFromRouteEnum.Faq), Seo = seo, SeoId = dbObject.SeoId }; return(faq); }
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); }
public override Recommendation ConvertDbObjectToEntity(PyramidFinalContext context, Recommendations dbObject) { var seo = new SeoRepository(context).Get(dbObject.SeoId.HasValue ? dbObject.SeoId.Value : 0); var recommend = new Recommendation() { Id = dbObject.Id, Content = dbObject.Content, ShortContent = dbObject.ShortContent, Title = dbObject.Title, Image = Convert.ConvertImageToEntity.Convert(dbObject.Images.FirstOrDefault()), FriendlyUrl = new RouteItemRepository(context).GetFriendlyUrl(dbObject.Id, Common.TypeEntityFromRouteEnum.RecommendationType), Seo = seo, SeoId = dbObject.SeoId }; return(recommend); }
public override FAQ ConvertDbObjectToEntity(PyramidFinalContext context, Faq dbObject) { var seo = new SeoRepository(context).Get(dbObject.SeoId.HasValue ? dbObject.SeoId.Value : 0); var faq = new FAQ() { Id = dbObject.Id, Title = dbObject.Title, FriendlyUrl = new RouteItemRepository(context).GetFriendlyUrl(dbObject.Id, Common.TypeEntityFromRouteEnum.Faq), Seo = seo, SeoId = dbObject.SeoId, QuestionAnswer = dbObject.QuestionAnswer.Select(s => new Pyramid.Entity.QuestionAnswer() { Answer = s.Answer, Id = s.Id, Question = s.Question }).ToList() }; return(faq); }
public override Event ConvertDbObjectToEntity(PyramidFinalContext context, Events dbObject) { var seo = new SeoRepository(context).Get(dbObject.SeoId.HasValue ? dbObject.SeoId.Value : 0); var products = new ProductRepository(context).Get(new SearchParamsProduct() { EventId = dbObject.Id }); var entity = new Event() { Content = dbObject.Content, Id = dbObject.Id, DateEventEnd = dbObject.DateEventEnd, DateEventStart = dbObject.DateEventStart, //Image=dbObject.EventImages. isActive = dbObject.isActive, Products = products.Objects, ShortContent = dbObject.ShortContent, Title = dbObject.Title, Seo = seo, SeoId = dbObject.SeoId, FriendlyUrl = new RouteItemRepository(context).GetFriendlyUrl(dbObject.Id, Common.TypeEntityFromRouteEnum.Event) }; if (dbObject.EventImages != null && dbObject.EventImages.ImageId.HasValue && dbObject.EventImages.Images != null) { var img = new Image() { Id = dbObject.EventImages.Images.Id, ImgAlt = dbObject.EventImages.Images.ImgAlt, ServerPathImg = dbObject.EventImages.Images.ServerPathImg, Title = dbObject.EventImages.Images.Title }; entity.Image = img; } return(entity); }
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); }