﻿using System.Web.Mvc;

namespace Subscription.Common
{
    public class PersistQueryStringsAttribute : ActionFilterAttribute
    {
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            bool ccApp;
            string ccAppValue = filterContext.HttpContext.Request.QueryString[Constants.CCAPP];
            if (ccAppValue != null &&
                bool.TryParse(ccAppValue, out ccApp))
            {
                filterContext.Controller.ViewBag.CCApp = ccApp;
            }
            else
            {
                filterContext.Controller.ViewBag.CCApp = false;
            }

            string employeeID = filterContext.HttpContext.Request.QueryString[Constants.EMPLOYEEID];
            filterContext.Controller.ViewBag.EmployeeID = employeeID;

            base.OnActionExecuting(filterContext);
        }
    }
}