Beispiel #1
0
        protected void ButtonEnviar_Click(object sender, EventArgs e)
        {

            Noticia noticia = new Noticia();
            noticia.TextoNoticia = TextBoxNoticia.Text;
            noticia.LinkNoticia = TextBoxLink.Text;
            noticia.UserName = System.Web.HttpContext.Current.User.Identity.Name;

            if (Request.QueryString["IdNoticia"] != null)
            {
                noticia.IdNoticia = Convert.ToInt64(HttpUtility.HtmlDecode(Request.QueryString["IdNoticia"]));
                noticia.AtualizaNoticia();

                if (FileUpload.HasFile)
                {
                    ResizeImage(noticia.IdNoticia);
                }
            }
            else
            {
                if (!FileUpload.HasFile)
                {
                    AnexoValidator.ErrorMessage = "Imagem da notícia não informada.";
                    AnexoValidator.IsValid = false;
                    return;
                }

                noticia.ImagemNoticia = FileUpload.FileName;
                noticia.InsereNoticia();

                ResizeImage(noticia.IdNoticia);
            }

            Cache.Remove("tableNoticias");

            Response.Redirect("~/Noticias.aspx");
        }