コード例 #1
0
        public ActionResult ExportarExcel()
        {
            int? SiteId = GetCurrentSite();

            HttpContext.Response.Clear();
            HttpContext.Response.AddHeader("content-disposition", string.Format("attachment;filename=Mailing_{0}.xls", DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss")));

            HttpContext.Response.ContentType = "application/ms-excel";
            HttpContext.Response.ContentEncoding = System.Text.Encoding.Default;

            //Mailing
            MailingDAL mailingDAL = new MailingDAL();
            List<MailingDTO> lista = mailingDAL.ListarMailing(null, SiteId);

            var tabela = new StringBuilder();

            CriarTagDeEstilo(tabela);

            CriarCabecalho(tabela);

            lista.ForEach(item => { CriarConteudo(tabela, item); });

            CriarTagDeRodape(tabela);

            HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache);
            HttpContext.Response.Write(tabela.ToString());
            HttpContext.Response.End();

            return null;
        }
コード例 #2
0
        public ActionResult ListarMailing()
        {
            int? SiteId = GetCurrentSite();
            int UsuarioId = 1;
            int IdiomaId = 1;

            //Mailing
            MailingDAL mailingDAL = new MailingDAL();
            List<MailingDTO> listaMailing = mailingDAL.ListarMailing(null, SiteId);

            return Json(listaMailing, JsonRequestBehavior.AllowGet);
        }
コード例 #3
0
        public ActionResult RegistrarMailing(string Nome, string Email, bool Cadastrar)
        {
            var currentSite = HttpContext.Request.Cookies["site"] != null ? HttpContext.Request.Cookies["site"].Value : "2";
            if (string.IsNullOrEmpty(currentSite)) currentSite = "0";
            int _siteId = Convert.ToInt32(currentSite);

            MailingDAL dal = new MailingDAL();
            MailingDTO mailing = new MailingDTO()
            {
                Nome = Nome,
                Email = Email,
                SiteId = _siteId,
                Ativo = Cadastrar
            };
            var resp = dal.RegistrarMailing(mailing);
            return Json(resp, JsonRequestBehavior.AllowGet);
        }