using System; using System.Net; using System.Web.Mvc; using EnVisage.Code; using EnVisage.Code.BLL; using EnVisage.Models; using Resources; namespace EnVisage.Controllers { [Authorize] public class SupplyDemandReportController : BaseController { [HttpGet] [AreaSecurity(area = Areas.CustomReports, level = AccessLevel.Read)] public ActionResult Index() { var model = new SupplyDemandReportFilterResponseModel(); return View(model); } [HttpPost] [ValidateJsonAntiForgeryToken] [AreaSecurity(area = Areas.CustomReports, level = AccessLevel.Read)] public ActionResult GetReport(SupplyDemandReportRequestModel model) { if (model == null) return new HttpStatusCodeResult(HttpStatusCode.BadRequest); try { ActivityCalendarModel reportModel; using (var reportManager = new SupplyDemandReportManager(DbContext)) { reportModel = reportManager.GetReportModel(SecurityManager.GetUserPrincipal(), model); } return BigJson(reportModel); } catch (Exception exception) { LogException(exception); } return new HttpStatusCodeResult(HttpStatusCode.InternalServerError); } [HttpPost] [ValidateJsonAntiForgeryToken] [AreaSecurity(area = Areas.CustomReports, level = AccessLevel.Read)] public ActionResult GetFilterOptions(SupplyDemandReportFilterRequestModel model) { try { var manager = new SupplyDemandReportManager(DbContext); var filter = manager.GetFilterOptions(SecurityManager.GetUserPrincipal(), model); if (filter == null) throw new InvalidOperationException(Messages.Common_OperationTerminated_FilterIsNull); return BigJson(filter); } catch (Exception exception) { LogException(exception); } return new HttpStatusCodeResult(HttpStatusCode.InternalServerError); } } }