protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (lbxPodcasts.SelectedIndex == -1)
        {
            DataLayer dl = new DataLayer();
            DateTime dtPostTime = DateTime.Now;
            int iEpisode = Convert.ToInt32(tbxEpisodeNumber.Text);
            FileInfo fi = new FileInfo(MapPath("~/KRNX/" + tbxURL.Text));
            decimal dSize = Math.Round((Convert.ToDecimal(fi.Length) / 1000m) / 1000m, 2);
            TagLib.File f = TagLib.File.Create(MapPath("~/KRNX/" + tbxURL.Text));
            decimal dDuration = Math.Round(Convert.ToDecimal(f.Properties.Duration.TotalMinutes), 1);
            dl.AddPodcast(tbxTitle.Text, rteDescription.Value, tbxURL.Text, dtPostTime, iEpisode, dSize, dDuration);

            //To Do: post to Twitter

            Session["resultColor"] = "#007700";
            Session["resultTitle"] = "Podcast Added";
            Session["resultMessage"] = "Podcast Added Successfuly";
            Session["resultReturnURL"] = "PodcastArchive.aspx";
            Response.Redirect("Result.aspx");
        }
        else
        {
            if (cbxDeletePodcast.Checked)
            {
                DataLayer dl = new DataLayer();
                dl.DeletePodcast(Convert.ToInt32(lbxPodcasts.SelectedValue));
                Session["resultColor"] = "#007700";
                Session["resultTitle"] = "Podcast Deleted";
                Session["resultMessage"] = "Podcast Deleted Successfuly";
                Session["resultReturnURL"] = "ManagePodcasts.aspx";
                Response.Redirect("Result.aspx");
            }
            else
            {
                DataLayer dl = new DataLayer();
                dl.UpdatePodcast(Convert.ToInt32(lbxPodcasts.SelectedValue), tbxTitle.Text, rteDescription.Value);
                Session["resultColor"] = "#007700";
                Session["resultTitle"] = "Podcast Updated";
                Session["resultMessage"] = "Podcast Updated Successfuly";
                Session["resultReturnURL"] = "ManagePodcasts.aspx";
                Response.Redirect("Result.aspx");
            }
        }
    }
Ejemplo n.º 2
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (lbxPodcasts.SelectedIndex == -1)
        {
            DataLayer   dl         = new DataLayer();
            DateTime    dtPostTime = DateTime.Now;
            int         iEpisode   = Convert.ToInt32(tbxEpisodeNumber.Text);
            FileInfo    fi         = new FileInfo(MapPath("~/KRNX/" + tbxURL.Text));
            decimal     dSize      = Math.Round((Convert.ToDecimal(fi.Length) / 1000m) / 1000m, 2);
            TagLib.File f          = TagLib.File.Create(MapPath("~/KRNX/" + tbxURL.Text));
            decimal     dDuration  = Math.Round(Convert.ToDecimal(f.Properties.Duration.TotalMinutes), 1);
            dl.AddPodcast(tbxTitle.Text, rteDescription.Value, tbxURL.Text, dtPostTime, iEpisode, dSize, dDuration);

            //To Do: post to Twitter

            Session["resultColor"]     = "#007700";
            Session["resultTitle"]     = "Podcast Added";
            Session["resultMessage"]   = "Podcast Added Successfuly";
            Session["resultReturnURL"] = "PodcastArchive.aspx";
            Response.Redirect("Result.aspx");
        }
        else
        {
            if (cbxDeletePodcast.Checked)
            {
                DataLayer dl = new DataLayer();
                dl.DeletePodcast(Convert.ToInt32(lbxPodcasts.SelectedValue));
                Session["resultColor"]     = "#007700";
                Session["resultTitle"]     = "Podcast Deleted";
                Session["resultMessage"]   = "Podcast Deleted Successfuly";
                Session["resultReturnURL"] = "ManagePodcasts.aspx";
                Response.Redirect("Result.aspx");
            }
            else
            {
                DataLayer dl = new DataLayer();
                dl.UpdatePodcast(Convert.ToInt32(lbxPodcasts.SelectedValue), tbxTitle.Text, rteDescription.Value);
                Session["resultColor"]     = "#007700";
                Session["resultTitle"]     = "Podcast Updated";
                Session["resultMessage"]   = "Podcast Updated Successfuly";
                Session["resultReturnURL"] = "ManagePodcasts.aspx";
                Response.Redirect("Result.aspx");
            }
        }
    }