public NewsItem GetNewsItem(int id) { var heart = _heartService.GetHeart(id); if (heart == null) { throw new UrlNotFoundException(); } var dataRes = _newsItemGateway.SelectOne(heart.HeartId); var res = Mapper.Map <NewsItem>(dataRes); res.FillHeart(heart); FillItem(res); return(res); }
public ActionResult Topic(int id) { Heart heart = _heartService.GetHeart(id); ICollection <CommentVM> comments = _commentService.GetThreadsByHeart(id); return(View(new Tuple <Heart, ICollection <CommentVM> >(heart, comments))); }
private void FillData(Manufacturer manufacturer) { var heart = _heartService.GetHeart(manufacturer.HeartId); manufacturer.FillHeart(heart); FillCountry(manufacturer); }
public Page GetPage(string url) { string cacheKey = GetPageCacheKey(url); return(GetFromCacheOrLoadAndAddToCache <Page>(cacheKey, () => { var heart = _heartService.GetHeart(url); if (heart == null) { throw new UrlNotFoundException(url); } var page = _pageGateway.SelectOne(heart.HeartId); var res = Mapper.Map <Page>(page); res.FillHeart(heart); return res; })); }
private void FillData(Action action) { var heart = _heartService.GetHeart(action.HeartId); action.FillHeart(heart); FillGoods(action); FillCats(action); FillManufaturers(action); }
private void Delete(int heartId) { var shopService = DependencyResolver.Current.GetService <IShopService>(); Data.Models.Category dataCategory = _categoryGateway.SelectOne(heartId); var goodsIds = _goodsCategoryGateway.SelectByCategory(heartId).Select(x => x.GoodsId); foreach (var goodsId in goodsIds) { var goodscats = _goodsCategoryGateway.SelectByGoods(goodsId); if (goodscats.Count() == 1) { shopService.DeleteGoods(goodsId); } } var childCats = _categoryGateway.Select(heartId); foreach (var child in childCats) { Delete(child.HeartId); } _categoryGateway.Delete(heartId); var heart = _heartService.GetHeart(heartId); _heartService.DeleteHeart(heartId); RemoveObjectFromCache("Categories"); RemoveObjectFromCache("AllCategories"); RemoveObjectFromCache($"ChildCategoriesFor{dataCategory.ParentCategoryId}"); RemoveObjectFromCache(GetCategoryCanonicalUrlCacheKey(heart.RelativeUrl)); RemoveObjectFromCache(GetCategoryIDCanonicalUrlCacheKey(dataCategory.HeartId)); int?lastCat = _settingsService.GetSettings <int?>("LastGoodsCategory"); if (lastCat.HasValue && lastCat.Value == heartId) { _settingsService.Set <int?>("LastGoodsCategory", null); } }
private void FillData(GoodsItem goodsItem, bool activeActionsOnly = true) { var heart = _heartService.GetHeart(goodsItem.HeartId); goodsItem.FillHeart(heart); goodsItem.CanonicalUrl = _heartService.GetCanonicalUrl(heart.HeartId); FillImages(goodsItem); FillCompatibles(goodsItem); FillCats(goodsItem); FillActions(goodsItem, activeActionsOnly); FillPacks(goodsItem); FillSpecs(goodsItem); FillManufacturers(goodsItem); goodsItem.Rating = _goodsReviewService.GetGoodsRating(goodsItem.HeartId); if (activeActionsOnly) { goodsItem.Actions.Clear(); goodsItem.Actions = _shopActionService.GetActiveActionsForGoodsItem(goodsItem.HeartId); } }
public IList <GoodsReview> GetAllGoodsReviews() { var dataRes = _goodsReviewGateway.Select(); var res = Mapper.Map <IList <GoodsReview> >(dataRes); foreach (var r in res) { r.GoodsItem = new GoodsItem() { HeartId = r.HeartId }; r.GoodsItem.FillHeart(_heartService.GetHeart(r.HeartId)); } return(res); }
public ActionResult CategorySEF(string relativeUrl, int?country, int?manufacturerId, int?packId, object specs, SortCriterion?sort, List <List <int> > catFilter = null, int?minPrice = null, int?maxPrice = null, string query = null) { string pageUrl = relativeUrl.Split('/').Last(); bool exists = _heartService.CheckIfUrlExists(pageUrl); if (!exists) { throw new HttpException(404, "Not found"); } var routeValues = Request.RequestContext.RouteData.Values; if (catFilter != null && (catFilter.Count() > 1 || catFilter.Any(x => x.Count() > 1))) { routeValues["relativeUrl"] = _shopUrl; return(RedirectPermanent(Url.RouteUrl(typeof(Page).FullName, routeValues))); } var cat = _heartService.GetHeart(pageUrl); if (catFilter != null && catFilter.Count() == 1 && catFilter.First().Count() == 1) { int catFilterId = catFilter.First().First(); if (cat.HeartId != catFilterId) { var filterCat = _heartService.GetHeart(catFilterId); routeValues["relativeUrl"] = filterCat.RelativeUrl; routeValues.Remove("cats"); return(RedirectPermanent(Url.RouteUrl(typeof(Category).FullName, routeValues))); } } var requestPath = Request.Path.Substring(1); if (!cat.CanonicalUrl.Equals(requestPath, StringComparison.InvariantCultureIgnoreCase)) { //routeValues["relativeUrl"] = cat.CanonicalUrl; return(RedirectPermanent(Url.RouteUrl(typeof(Category).FullName, routeValues))); } int id = cat.HeartId; int page = ViewBag.Page; int pgsize = ViewBag.PageSize; var filter = new GoodsFilter() { CategoryIds = new[] { new[] { id } }, ClientMode = true, MinPrice = minPrice, MaxPrice = maxPrice, SearchPattern = query }; var goods = GetGoodsPage(filter, sort, (Dictionary <int, string>)specs, packId, country, manufacturerId, page, pgsize); ViewBag.PagingRoute = typeof(Category).FullName; ViewBag.CategoryId = id; TempData["MetaKeywords"] = cat.MetaKeywords; TempData["MetaDescription"] = cat.MetaDescription; TempData["AdditionalHeaders"] = cat.AdditionalHeaders; return(PartialView("GoodsPage", goods)); }