using Foresight.Fleet.Services.User;
using IronIntel.Contractor;
using IronIntel.Contractor.Site;
using IronIntel.Contractor.Site.Asset;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class AssetMergeHistory : AssetBasePage
{


    protected void Page_Load(object sender, EventArgs e)
    {
        if (!CheckLoginSession())
        {
            RedirectToLoginPage();
        }
        else
        {
            string methodName = Request.Form["MethodName"];
            if (!string.IsNullOrEmpty(methodName))
            {
                ProcessRequest(methodName);
            }
            else if (!IsPostBack)
            {
                this.Title = PageTitle;
                if ((int)GetCurrentUser().UserType != (int)UserTypes.SupperAdmin)
                    RedirectToLoginPage();

                bool permission = CheckRight(SystemParams.CompanyID, Feature.MANAGE_ASSETS);
                if (!permission)
                    RedirectToLoginPage();
            }
        }
    }

    protected override bool ThrowIfNotAllowed
    {
        get
        {
            return true;
        }
    }

    protected override bool AllowCurrentLoginSessionEnter()
    {
        var f = base.AllowCurrentLoginSessionEnter();
        if (!f)
        {
            return false;
        }

        var user = GetCurrentUser();
        return user != null && user.UserType >= IronIntel.Contractor.Users.UserTypes.Common;
    }

    public bool IsAdmin
    {
        get
        {
            var user = GetCurrentUser();
            if (user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin || user.UserType == IronIntel.Contractor.Users.UserTypes.Admin)
                return true;
            else
                return false;
        }

    }

}