Ejemplo n.º 1
0
        public override void Get(HttpRequest Request, HttpResponse Response, params string[] PathParams)
        {
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Cache.SetMaxAge(TimeSpan.Zero);

            try
            {
                int bannerId = (Request.QueryString["prom_img_id"] != null ? Int32.Parse(Request.QueryString["prom_img_id"].ToString()) : 0);
                var banner   = Advertisement.FetchByID(bannerId);
                HandleImageRequest(Response, banner.FilePath);
            }
            catch (Exception) { }
        }
Ejemplo n.º 2
0
    protected void LoadView()
    {
        string[] itemNames  = System.Enum.GetNames(typeof(BunnerType));
        Array    itemValues = System.Enum.GetValues(typeof(BunnerType)).Cast <int>().ToArray();

        for (int i = 0; i <= itemValues.Length - 1; i++)
        {
            string   localizationValue = ResourceManagerAccessor.GetText("Advertisements", itemNames[i]);
            ListItem item = new ListItem(localizationValue, itemValues.GetValue(i).ToString());
            ddlBunner.Items.Add(item);
        }
        ddlBunner.DataBind();
        ddlBusinessName.DataSource     = AdvertisementController.GetAllCompanies();
        ddlBusinessName.DataValueField = "Key";
        ddlBusinessName.DataTextField  = "Value";
        ddlBusinessName.DataBind();

        if (AdId > 0)
        {
            Advertisement advertisement = Advertisement.FetchByID(AdId);

            ddlBusinessName.SelectedValue = advertisement.CompanyId.ToString();
            txtFromDate.Text = advertisement.FromDate.ToString();
            txtToDate.Text   = advertisement.ToDate.ToString();
            href.Text        = advertisement.Href;

            ddlBunner.SelectedValue = ((int)advertisement.BunnerId).ToString();

            if (!string.IsNullOrEmpty(advertisement.FilePath))
            {
                HomeImage.ImageUrl = MediaUtility.GetImagePath("Banners", advertisement.FilePath, 0, 64, 64);
                HomeImage.ImageUrl = HomeImage.ImageUrl.Contains(".") ? HomeImage.ImageUrl : "";
                ImageFileHandler(fuImage, HomeImage, btnDeleteImage, HomeImage.ImageUrl);
            }
        }
    }
Ejemplo n.º 3
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (!Page.IsValid)
        {
            return;
        }

        Advertisement advertisement = null;

        if (!IsNewMode)
        {
            advertisement = Advertisement.FetchByID(AdId);
        }
        else
        {
            advertisement             = new Advertisement();
            advertisement.CreatedDate = DateTime.Now;
        }
        advertisement.BunnerId  = (BunnerType)Enum.Parse(typeof(BunnerType), ddlBunner.SelectedValue);
        advertisement.CompanyId = Convert.ToInt64(ddlBusinessName.SelectedValue);


        if (fuImage.HasFile)
        {
            MediaUtility.DeleteImageFilePath("Banners", advertisement.FilePath, 64, 64, 0);
            string fn = MediaUtility.SaveFile(fuImage.PostedFile, "Banners", 0);
            advertisement.FilePath = fn;
            HomeImage.ImageUrl     = Snoopi.core.MediaUtility.GetImagePath("Banners", advertisement.FilePath, 0, 64, 64);
            ImageFileHandler(fuImage, HomeImage, btnDeleteImage, HomeImage.ImageUrl);
        }
        else if (advertisement.FilePath != "" && fuImage.Visible)
        {
            MediaUtility.DeleteImageFilePath("Banners", Settings.GetSetting(Settings.Keys.BANNER_HOME), 64, 64, 0);
            advertisement.FilePath = "";
        }

        DateTime fDate = DateTime.MinValue;
        DateTime tDate = DateTime.MinValue;

        DateTime.TryParse(txtFromDate.Text, out fDate);
        DateTime.TryParse(txtToDate.Text, out tDate);
        advertisement.FromDate = fDate;
        advertisement.ToDate   = tDate;
        advertisement.Href     = href.Text;

        advertisement.Save();


        if (IsNewMode)
        {
            string successMessage = AdvertisementsStrings.GetText(@"MessageCompanyCreated");
            string url            = @"EditAd.aspx?AdId=" + advertisement.Id;
            url += @"&message-success=" + Server.UrlEncode(successMessage);
            Response.Redirect(url, true);
        }
        else
        {
            string successMessage = AdvertisementsStrings.GetText(@"MessageAdSaved");

            Master.MessageCenter.DisplaySuccessMessage(successMessage);
            LoadView();
        }
    }