Example #1
0
        public ActionResult Unsubscribe(string hash)
        {
            var id = ToolService.GetIdBHash(hash);

            if (!id.HasValue)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
            }

            var objNewsletter = Newsletter.Load(id.Value);

            if (objNewsletter == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
            }

            var model = new NewsletterUnsubscribeViewModel
            {
                //Base
                Title       = "Descadastrar e-mail - Massa News",
                Description = "Estamos tristes, mas esperamos que volte algum dia.",
                Robots      = "noindex, nofollow",
                Canonical   = $"{Constants.UrlWeb}/newsletter/descadastrar",
                //Model
                UserHash       = hash,
                UserNewsletter = objNewsletter
            };

            ViewBag.ActiveNav = "Descadastrar";

            return(View(model));
        }
Example #2
0
        public ActionResult Unsubscribe(NewsletterUnsubscribe model)
        {
            var id = ToolService.GetIdBHash(model.Hash);

            var objNewsletter = Newsletter.Load(id.Value);

            objNewsletter.Ativo    = false;
            objNewsletter.MotivoId = model.Reason;

            objNewsletter.Save();

            return(Json("ok"));
        }
Example #3
0
        public ActionResult Update(string hash)
        {
            var id = ToolService.GetIdBHash(hash);

            if (!id.HasValue)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
            }

            var objNewsletter = Newsletter.Load(id.Value);

            if (objNewsletter == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
            }

            var goback = false;

            if (!objNewsletter.Ativo)
            {
                goback = true;
                objNewsletter.Ativo    = true;
                objNewsletter.MotivoId = null;
                objNewsletter.Save();
            }

            var model = new NewsletterUpdateViewModel
            {
                //Base
                Title       = "Atualizar preferências de e-mail - Massa News",
                Description = "Atualize suas preferências e receba e-mails personalizados para você.",
                Robots      = "noindex, nofollow",
                Canonical   = $"{Constants.UrlWeb}/newsletter/atualizar",
                //Model
                UserHash         = hash,
                GoBack           = goback,
                PreferenceGroups = PreferenceGroup.GetAll(),
                UserNewsletter   = objNewsletter
            };

            ViewBag.ActiveNav  = "Preferências de e-mail";
            ViewBag.CityLetter = new SelectList(Cidade.GetAllToDictionary(), "Key", "Value", objNewsletter.CidadeId);

            return(View(model));
        }
Example #4
0
        public ActionResult Update(NewsletterUpdate model)
        {
            var id = ToolService.GetIdBHash(model.Hash);

            var objNewsletter = Newsletter.Load(id.Value);

            objNewsletter.Nome      = model.Name;
            objNewsletter.Celular   = model.CellPhone;
            objNewsletter.CidadeId  = model.City;
            objNewsletter.PeriodoId = model.Period;

            if (model.Preferences != null)
            {
                objNewsletter.SelectedPreferences = model.Preferences.ToList();
            }

            objNewsletter.Save();

            return(Json("ok"));
        }
Example #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                Guid id     = Guid.Empty;
                Guid newsid = Guid.Empty;
                if (!String.IsNullOrEmpty(Request.Params["ID"]))
                {
                    id = new Guid(Request.Params["ID"]);
                }
                else if (Request["newsletterid"] != null)
                {
                    if (!String.IsNullOrEmpty(Request.Params["newsletterid"]))
                    {
                        newsid = new Guid(Request.Params["newsletterid"]);
                    }
                    Newsletter imageNews = new Newsletter();

                    imageNews            = Newsletter.Load(newsid);
                    Response.ContentType = "image/jpeg";
                    if (imageNews != null && imageNews.Image != null)
                    {
                        MemoryStream ms = new MemoryStream(imageNews.Image);
                        // create an image object, using the filename we just retrieved
                        System.Drawing.Image imageOriginal = System.Drawing.Image.FromStream(ms);

                        // create the actual thumbnail image
                        System.Drawing.Image thumbnailImage = imageOriginal.GetThumbnailImage(171, 116, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero);

                        // make a memory stream to work with the image bytes
                        MemoryStream imageStream = new MemoryStream();

                        // put the image into the memory stream
                        thumbnailImage.Save(imageStream, System.Drawing.Imaging.ImageFormat.Jpeg);

                        // make byte array the same size as the image
                        byte[] imageContent = new Byte[imageStream.Length];

                        // rewind the memory stream
                        imageStream.Position = 0;

                        // load the byte array with the image
                        imageStream.Read(imageContent, 0, (int)imageStream.Length);

                        // return byte array to caller with image type
                        Response.ContentType = "image/jpeg";
                        Response.BinaryWrite(imageContent);

                        //Response.BinaryWrite(img.Thumbnail);
                        ms.Dispose();
                        imageStream.Dispose();
                    }
                    else
                    {
                        Response.WriteFile("~/images/EmptyImage.png");
                    }
                }
                PropertyImage image = new PropertyImage();
                image.Id = id;
                if (Request["banner"] != null)
                {
                    image = image.GetByIdbanner();
                }
                else
                {
                    image = image.GetById();
                }
                Response.ContentType = "image/jpeg";
                if (image == null)
                {
                    Response.WriteFile("~/images/EmptyImage.png");
                }
                //else if (string.IsNullOrEmpty(Request["big"]))
                //{
                //    MemoryStream ms = new MemoryStream(image.Image);
                //    // create an image object, using the filename we just retrieved
                //    System.Drawing.Image imageOriginal = System.Drawing.Image.FromStream(ms);

                //    // create the actual thumbnail image
                //    System.Drawing.Image thumbnailImage = imageOriginal.GetThumbnailImage(171, 116, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero);

                //    // make a memory stream to work with the image bytes
                //    MemoryStream imageStream = new MemoryStream();

                //    // put the image into the memory stream
                //    thumbnailImage.Save(imageStream, System.Drawing.Imaging.ImageFormat.Jpeg);

                //    // make byte array the same size as the image
                //    byte[] imageContent = new Byte[imageStream.Length];

                //    // rewind the memory stream
                //    imageStream.Position = 0;

                //    // load the byte array with the image
                //    imageStream.Read(imageContent, 0, (int)imageStream.Length);

                //    // return byte array to caller with image type
                //    Response.ContentType = "image/jpeg";
                //    Response.BinaryWrite(imageContent);

                //    //Response.BinaryWrite(img.Thumbnail);
                //    ms.Dispose();
                //    imageStream.Dispose();

                //}
                else if (!string.IsNullOrEmpty(Request["med"]))
                {
                    //GetFullImage(image);
                    //return;
                    MemoryStream ms = new MemoryStream(image.Image);
                    // create an image object, using the filename we just retrieved
                    System.Drawing.Image imageOriginal = System.Drawing.Image.FromStream(ms);

                    // create the actual thumbnail image
                    System.Drawing.Image thumbnailImage = imageOriginal.GetThumbnailImage(600, 404, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero);

                    // make a memory stream to work with the image bytes
                    MemoryStream imageStream = new MemoryStream();

                    // put the image into the memory stream
                    thumbnailImage.Save(imageStream, System.Drawing.Imaging.ImageFormat.Jpeg);

                    // make byte array the same size as the image
                    byte[] imageContent = new Byte[imageStream.Length];

                    // rewind the memory stream
                    imageStream.Position = 0;

                    // load the byte array with the image
                    imageStream.Read(imageContent, 0, (int)imageStream.Length);

                    // return byte array to caller with image type
                    Response.ContentType = "image/jpeg";
                    Response.BinaryWrite(imageContent);

                    //Response.BinaryWrite(img.Thumbnail);
                    ms.Dispose();
                    imageStream.Dispose();
                }
                else if (!string.IsNullOrEmpty(Request["small"]))
                {
                    //GetFullImage(image);
                    //return;
                    MemoryStream ms = new MemoryStream(image.Image);
                    // create an image object, using the filename we just retrieved
                    System.Drawing.Image imageOriginal = System.Drawing.Image.FromStream(ms);

                    // create the actual thumbnail image
                    System.Drawing.Image thumbnailImage = imageOriginal.GetThumbnailImage(396, 276, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero);

                    // make a memory stream to work with the image bytes
                    MemoryStream imageStream = new MemoryStream();

                    // put the image into the memory stream
                    thumbnailImage.Save(imageStream, System.Drawing.Imaging.ImageFormat.Jpeg);

                    // make byte array the same size as the image
                    byte[] imageContent = new Byte[imageStream.Length];

                    // rewind the memory stream
                    imageStream.Position = 0;

                    // load the byte array with the image
                    imageStream.Read(imageContent, 0, (int)imageStream.Length);

                    // return byte array to caller with image type
                    Response.ContentType = "image/jpeg";
                    Response.BinaryWrite(imageContent);

                    //Response.BinaryWrite(img.Thumbnail);
                    ms.Dispose();
                    imageStream.Dispose();
                }
                else
                {
                    GetFullImage(image);
                }
                if (Request["slide"] != null)
                {
                    GetFullImage(image);
                }
            }
        }