public string RenderToProductInformation(int productId) { var discountModel = BuyInTimeService.GetByProduct(productId, DateTime.Now); if (discountModel == null) { return(string.Empty); } var actionTitle = ModuleSettingsProvider.GetSettingValue <string>("BuyInTimeActionTitle", ModuleStringId); var countdown = discountModel.DateExpired != null ? string.Format(BuyInTimeService.CountdownScript, ((DateTime)discountModel.DateExpired).ToString("dd.MM.yyyy HH:mm:ss")) : string.Empty; return(string.Format("<div class=\"buy-in-time-product\"><div class=\"buy-in-time-action-b\">{0}</div> {1}</div>", actionTitle, countdown)); }
public ProductLabel GetLabel() { var labelCode = ModuleSettingsProvider.GetSettingValue <string>("BuyInTimeLabel", ModuleStringId); if (labelCode.IsNullOrEmpty()) { return(null); } var productDiscounts = BuyInTimeService.GetProductDiscountsList(DateTime.Now); if (productDiscounts == null || productDiscounts.Count == 0) { return(null); } return(new ProductLabel() { LabelCode = labelCode, ProductIds = productDiscounts.Select(p => p.ProductId).ToList() }); }
public bool UpdateModule() { return(BuyInTimeService.UpdateBuyInTimeModule()); }
public bool UninstallModule() { return(BuyInTimeService.UninstallBuyInTimeModule()); }
public bool InstallModule() { return(BuyInTimeService.InstallBuyInTimeModule() && BuyInTimeService.UpdateBuyInTimeModule()); }
public string RenderMainPageAfterCarousel() { var cacheKey = BuyInTimeService.CacheKey + BuyInTimeService.eShowMode.Vertical; if (CacheManager.Contains(cacheKey)) { return(CacheManager.Get <string>(cacheKey)); } var action = BuyInTimeService.GetByShowMode((int)BuyInTimeService.eShowMode.Vertical, DateTime.Now); var actionHorizontal = BuyInTimeService.GetByShowMode((int)BuyInTimeService.eShowMode.Horizontal, DateTime.Now); if (actionHorizontal != null && action != null && action.Id < actionHorizontal.Id) { CacheManager.Insert(cacheKey, ""); return(string.Empty); } if (action != null) { if (action.IsRepeat && action.DateExpired < DateTime.Now) { action.DateExpired = BuyInTimeService.GetExpireDateTime(action.DateExpired, action.DaysRepeat); } var actionTitle = ModuleSettingsProvider.GetSettingValue <string>("BuyInTimeActionTitle", ModuleStringId); var countdown = string.Format(BuyInTimeService.CountdownScript, action.DateExpired.ToString("dd.MM.yyyy HH:mm:ss")); var actionText = action.ActionText.Replace("#ActionTitle#", actionTitle) .Replace("#Countdown#", countdown); var product = ProductService.GetProduct(action.ProductId); if (product == null) { return(actionText); } var offer = product.Offers.FirstOrDefault(o => o.Main) ?? product.Offers.FirstOrDefault(); if (offer == null) { return(actionText); } actionText = actionText.Replace("#ProductPicture#", action.Picture.IsNotEmpty() ? string.Format("<img src=\"modules/{0}/pictures/{1}\" />", ModuleStringId.ToLower(), action.Picture) : string.Empty) .Replace("#ProductLink#", UrlService.GetLink(ParamType.Product, product.UrlPath, product.ProductId)) .Replace("#ProductName#", product.Name) .Replace("#OldPrice#", CatalogService.GetStringPrice(offer.Price).Replace("руб", "р")) .Replace("#NewPrice#", CatalogService.GetStringPrice(offer.Price, action.DiscountInTime).Replace("руб", "р")) .Replace("#DiscountPrice#", CatalogService.GetStringPrice(offer.Price * action.DiscountInTime / 100).Replace("руб", "р")) .Replace("#DiscountPercent#", action.DiscountInTime.ToString("0.##")); CacheManager.Insert(cacheKey, actionText); return(actionText); } return(string.Empty); }
public List <ProductDiscount> GetProductDiscountsList() { return(BuyInTimeService.GetProductDiscountsList(DateTime.Now)); }
public float GetDiscount(int productId) { var model = BuyInTimeService.GetByProduct(productId, DateTime.Now); return(model != null ? model.Discount : 0); }