﻿using System;
using System.Web;
using System.Web.Mvc;
using SOURCE.Infrastructure.Attributes.Modularity.Plugins;
using SOURCE.Infrastructure.Services.Depots;
using SOURCE.Infrastructure.Services.Encryption;
using SOURCE.Infrastructure.Services.Parameters;
using Castle.Core.Logging;

namespace SOURCE.Web.Controllers.Modularity.Plugins
{
    [Plugin(Priority = 10)]
    public class CookiePlugin : IModularityPlugin
    {
        public void OnActionExecuting(HttpContextBase context, ActionExecutingContext filterContext, IDepotFactory depotFactory, ICryptography encryption, IParameter parameter, ILogger logger)
        {
            var controller = filterContext.Controller;

            if (context.Session["Cookie.PromotionReceived"] != null)
                controller.ViewData["Cookie.PromotionReceived"] = Convert.ToBoolean(HttpContext.Current.Session["AVuPromo"]);
        }

        public void OnActionExecuted(HttpContextBase context, ActionExecutingContext filterContext, IDepotFactory depotFactory, ICryptography encryption, IParameter parameter, ILogger logger)
        {
        }
    }
}
