37 lines
1.1 KiB
C#
37 lines
1.1 KiB
C#
using EnVisage.Code.Cache;
|
|
using System;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.Mvc;
|
|
using EnVisage.Code;
|
|
using Microsoft.AspNet.Identity;
|
|
|
|
namespace EnVisage.Controllers
|
|
{
|
|
[Authorize]
|
|
public class HomeController : BaseController
|
|
{
|
|
public ActionResult Index()
|
|
{
|
|
var user = new UsersCache().Value.FirstOrDefault(x => x.Id == new Guid(HttpContext.User.Identity.GetUserId()));
|
|
if (user != null)
|
|
ViewBag.IsUOMHours = !user.PreferredResourceAllocation;
|
|
|
|
return View();
|
|
}
|
|
|
|
public ActionResult ExportToPDF()
|
|
{
|
|
//Logger.Log(NLog.LogLevel.Debug, "PDF EXPORT REQUESTED URL:" + Url.Action("Index", "Home", null, this.Request.Url.Scheme));
|
|
|
|
PDFExporter exporter = new PDFExporter();
|
|
byte[] pdfBuffer = exporter.ExportPage(Url.Action("Index", "Home", null, this.Request.Url.Scheme), 3, true, Request.Cookies);
|
|
|
|
// send the PDF file to browser
|
|
FileResult fileResult = new FileContentResult(pdfBuffer, "application/pdf");
|
|
fileResult.FileDownloadName = "PlanIT-Dashboard-" + DateTime.Today.Month + "-" + DateTime.Today.Day + ".pdf";
|
|
|
|
return fileResult;
|
|
}
|
|
}
|
|
} |