/// <summary> /// GET: /Orders/ /// </summary> /// <returns></returns> public ActionResult Index() { if (Session["usertype"] != null) // If some user is logged in { if (Session["usertype"].ToString() == "Admin") { return(View(LetsShopImplementation.GetAllOrders())); } else { return(RedirectToAction("Index", "Home")); } } else { return(RedirectToAction("Index", "Home")); } }
//______________________________________________________________________________________ /// <summary> /// GET: /Orders/ExportAllOrders [Exports all users to an Excel File] /// </summary> /// <returns></returns> public ActionResult ExportAllOrders() { try { GridView gv = new GridView(); gv.DataSource = LetsShopImplementation.GetAllOrders(); gv.DataBind(); Response.ClearContent(); Response.AddHeader("content-disposition", "attachment; filename=AllOrders.xls"); Response.ContentType = "application/excel"; StringWriter sw = new StringWriter(); HtmlTextWriter htw = new HtmlTextWriter(sw); gv.RenderControl(htw); Response.Write(sw.ToString()); Response.End(); } catch (Exception) { return(RedirectToAction("ErrorPage", "Product")); } return(View("Index")); }