예제 #1
0
        public ActionResult ExportToExcel()
        {
            var rvspService = new RvspService();
            var ds          = rvspService.ModifiedRvsp();

            var data = from s in ds
                       select new
            {
                s.Namn,
                s.Email,
                s.Kommer,
                s.Boende,
                s.AntalNätter,
                s.MatInfo,
                s.Kommentar,
            };

            var list = data.ToList();
            var grid = new GridView();

            grid.DataSource = list;
            grid.DataBind();
            Response.ClearContent();
            Response.AddHeader("content-disposition", "attachment; filename=Bröllop_OSA.xls");
            Response.ContentType = "application/vnd.ms-excel";
            StringWriter   sw  = new StringWriter();
            HtmlTextWriter htw = new HtmlTextWriter(sw);

            grid.RenderControl(htw);
            Response.Write(sw.ToString());
            Response.End();

            return(View("Index", ds));
        }
예제 #2
0
        public ActionResult Index(RvspModel rvsp)
        {
            RvspService rvspService = new RvspService();
            bool        success     = rvspService.SaveRvsp(rvsp);

            if (!success)
            {
                TempData["rvsp"] = "Något blev fel. Försök igen";
                return(new RedirectResult(Url.Action("Index") + "#rvsp"));
            }

            TempData["rvsp"] = $"Bra jobbat! Ett bekräftelsemail skickas till {rvsp.Email}.";

            return(new RedirectResult(Url.Action("Index") + "#rvsp"));
        }
예제 #3
0
        public ActionResult Index()
        {
            var requestCookie = Request.Cookies["AuthID"];

            try
            {
                if (requestCookie == null || requestCookie.Value != Session["AuthID"].ToString())
                {
                    return(View("Index"));
                }
            }
            catch
            {
                return(View("Index"));
            }
            var rvspService = new RvspService();
            var rvsp        = rvspService.ModifiedRvsp();

            return(View(rvsp));
        }