object gridBanners_OnExternalDataBound(object sender, string sourceName, object parameter) { switch (sourceName.ToLowerCSafe()) { case "bannertype": BannerTypeEnum bannerType = (BannerTypeEnum)(int)parameter; return(HTMLHelper.HTMLEncode(ResHelper.GetString("banner.bannertype." + bannerType.ToString().ToLowerCSafe()))); case "hitsclicksleft": if (parameter == DBNull.Value) { return("<i>" + GetString("general.unlimited") + "</i>"); } int value = (int)parameter; if (value == 0) { return("<span class=\"StatusDisabled\">" + value + "</span>"); } return(value); case "delete": DataRow row = ((DataRowView)((GridViewRow)parameter).DataItem).Row; int?siteID = row.IsNull("BannerSiteID") ? (int?)null : ValidationHelper.GetInteger(row["BannerSiteID"], 0); string iconName; ImageButton button = ((ImageButton)sender); if (HasUserModifyPermission(siteID)) { iconName = "Delete"; } else { iconName = "Deletedisabled"; button.Enabled = false; } button.ImageUrl = GetImageUrl("Design/Controls/UniGrid/Actions/" + iconName + ".png"); break; } return(parameter); }
public static List <Banner> GetActiveBanners(BannerTypeEnum bannerType) { using (var context = new BackofficeUnitOfWork()) { return(context.Banner .Fetch() .Include(i => i.BannerType) .Where(i => i.Active && i.BannerType.Token == bannerType.ToString() && i.StartDate < DateTime.Now && (!i.DueDate.HasValue || i.DueDate.Value > DateTime.Now)) .Select(i => i) .OrderBy(i => Guid.NewGuid()) .ToList()); } }
object gridBanners_OnExternalDataBound(object sender, string sourceName, object parameter) { switch (sourceName.ToLowerCSafe()) { case "bannertype": BannerTypeEnum bannerType = (BannerTypeEnum)(int)parameter; return(HTMLHelper.HTMLEncode(ResHelper.GetString("BannerTypeEnum." + bannerType.ToString().ToLowerCSafe()))); case "hitsclicksleft": if (parameter == DBNull.Value) { return(GetString("general.unlimited")); } int value = (int)parameter; if (value == 0) { return("<span class=\"StatusDisabled\">" + value + "</span>"); } return(value); case "delete": DataRow row = ((DataRowView)((GridViewRow)parameter).DataItem).Row; int?siteID = row.IsNull("BannerSiteID") ? (int?)null : ValidationHelper.GetInteger(row["BannerSiteID"], 0); CMSGridActionButton button = ((CMSGridActionButton)sender); if (!HasUserModifyPermission(siteID)) { button.Enabled = false; } break; } return(parameter); }