using FI.FIC;
using FI.FIC.Contracts.DataObjects.BaseObject;
using Foresight.Fleet.Services.Asset;
using Foresight.Fleet.Services.JobSite;
using Foresight.Fleet.Services.User;
using Foresight.Standard;
using IronIntel.Contractor.Machines;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IronIntel.Contractor.Users
{
    public class UserInfo
    {
        private static string[] ContactTypeNames = { "Foreman", "Driver", "Inventory Manager", "Rental Manager", "Service Manager", "Fleet Manager", "Technician", "Advisor", "Other" };
        public string IID { get; set; }
        public string ID { get; set; }
        public string DisplayName { get; set; }
        public string TextAddress { get; set; }
        public bool IsUser { get; set; }
        public ContactTypes ContactType { get; set; }
        public string Mobile { get; set; }
        public string MobilePhoneDisplayText { get; set; }
        public string BusinessPhone { get; set; }
        public string Notes { get; set; }
        public bool Active { get; set; }
        public UserTypes UserType { get; set; }
        public string TransPass { get; set; }
        public string ManagerIID { get; set; }
        public string ManagerName { get; set; }
        public bool AssignedWorkOrders { get; set; }
        public bool EmailOptOut { get; set; }
        public bool InspectEmailList { get; set; }
        public bool TeamIntelligenceUser { get; set; }
        public string FOB { get; set; }
        public decimal HourlyRate { get; set; }
        public string[] GroupIDs { get; set; }
        public string[] GroupNames { get; set; }
        public bool AllowLoginIntoPC { get; set; }
        public bool AllowLoginIntoInspectMobile { get; set; }
        public bool AllowLoginIntoFleetMobile { get; set; }
        public bool AllowMobileBarcodeScanning { get; set; }
        public string PreferredLanguage { get; set; }
        public string TimeZone { get; set; }
        public string LandingPage { get; set; }
        public string GroupNamesStr { get { return (GroupNames == null || GroupNames.Length == 0) ? "" : string.Join(",", GroupNames); } }

        public long[] AssetIDs { get; set; }
        public string[] AssetGroupIDs { get; set; }
        public string[] JobsiteIDs { get; set; }
        public string[] AssetTypeIDs { get; set; }
        public int[] LocationIds { get; set; }
        public int[] DepartmentIds { get; set; }
        public bool WorkOrderFollower { get; set; }
        public bool ExcelExports { get; set; }
        public LoginVerifyTypes LoginVerifyType { get; set; } = LoginVerifyTypes.OrganizationSetting;
        public UserInfo[] Managers { get; set; }
        public string ContactTypeName
        {
            get
            {
                int cType = (int)ContactType;
                if (cType > 8)
                    cType = 8;
                return ContactTypeNames[cType];
            }
        }
    }

    public class UserObject
    {
        public UserInfo UserInfo { get; set; }
        public SubscribeMessageByEmail Subscribe { get; set; }
        public KeyValuePair<int, Foresight.Fleet.Services.User.Permissions[]>[] Features { get; set; }

        public string UserAlertFilter { get; set; }

        public EmailSchedule Schedule { get; set; }
        public StringKeyValue[] MessageTypes { get; set; }
        public UserFilterTemplateItem[] FilterTemplates { get; set; }
        public int[] DeleteFilterTemplates { get; set; }
    }

    public enum UserTypes
    {
        Readonly = 0,
        Common = 1,
        Admin = 2,
        SupperAdmin = 3
    }
    public enum ContactTypes
    {
        Foreman = 0,
        Driver = 1,
        InventoryManager = 2,
        RentalManager = 3,
        ServiceManager = 4,
        FleetManager = 5,
        Technician = 6,
        Advisor = 7,
        Other = 100
    }

    public class UserNameInfoItem
    {
        public string IID { get; set; }
        public string ID { get; set; }
        public string Name { get; set; }
    }

    public class UserFilterTemplateItem
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public AssetListItemInfo[] Assets { get; set; }
        public MachineGroup[] AssetGroups { get; set; }
        public AssetType[] AssetTypes { get; set; }
        public JobSiteItem[] Jobsites { get; set; }
    }

}