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

public partial class ManageGPSDevices : MachineDeviceBasePage
{
    public bool IsDealer = IronIntel.Contractor.SystemParams.IsDealer;

    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;
                //bool permission = CheckRight(SystemParams.CompanyID, Feature.MANAGE_ASSETS);
                //if (!permission)
                //    RedirectToLoginPage();
            }
        }
    }

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

        var user = GetCurrentUser();
        bool isallowed = CheckRight(SystemParams.CompanyID, Foresight.Fleet.Services.User.Feature.MANAGE_DEVICES);
        //bool isallowed = IronIntel.Contractor.Users.UserManagement.CheckUserPermission(GetCurrentLoginSession().SessionID, user.IID, 10);
        return isallowed || (user != null && user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin);
    }

    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;
        }
    }
    public bool IsSuperAdmin
    {
        get
        {
            var user = GetCurrentUser();
            if (user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin)
                return true;
            else
                return false;
        }
    }
}