using Foresight;
using Foresight.Fleet.Services.Asset;
using Foresight.Fleet.Services.MapView;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IronIntel.Contractor.MapView
{
    public class AssetViewItem
    {
        public long ID { get; set; }
        public string VIN { get; set; }
        public string Name { get; set; }
        public string Name2 { get; set; }
        public string Make { get; set; }
        public string Model { get; set; }
        public int Priority { get; set; }
        public string AssetType { get; set; }
        public double Latitude { get; set; }
        public double Longitude { get; set; }
        public string IconUrl { get; set; }
        public string AlertTips { get; set; }
        public List<string> AssetGroups { get; set; }
        public List<long> JobSites { get; set; }
        public string ShowName
        {
            get
            {
                //Name取值顺序为Name2,Name,VIN,ID用于前端显示
                string name = Name2;
                if (string.IsNullOrWhiteSpace(name))
                    name = Name;
                if (string.IsNullOrWhiteSpace(name))
                    name = VIN;
                if (string.IsNullOrWhiteSpace(name))
                    name = ID.ToString();
                return name;
            }
        }//由于地图显示及排序的名称

    }
    public class AssetDetailViewItem
    {
        private double _EngineHours;
        public double EngineHours
        {
            get
            {
                return _EngineHours;
            }
            set
            {
                value = value > 0 ? value : 0;
                _EngineHours = Math.Round(value, 2);
            }
        }
        public DateTime EngineHoursDate { get; set; }
        public string GroupNames { get; set; }

        private double _Odometer;
        public double Odometer
        {
            get
            {
                return _Odometer;
            }
            set
            {
                value = value > 0 ? value : 0;
                _Odometer = Math.Round(value, 2);
            }
        }
        public string OdometerUOM { get; set; }
        public int MakeYear { get; set; }
        public string AssetType { get; set; }
        public string Model { get; set; }
        public string Make { get; set; }
        public string VIN { get; set; }
        public string Name2 { get; set; }
        public string Name { get; set; }
        public long ID { get; set; }
        public string IconUrl { get; set; }
        public string AssetIconUrl { get; set; }
        public LocationViewItem Location { get; set; }
        public string EngineHoursDateText
        {
            get
            {
                if (EngineHoursDate != DateTime.MinValue)
                {
                    return EngineHoursDate.ToString();
                }
                return "";
            }
        }
    }

    public class AssetLocationHistoryViewItem
    {
        public AssetViewItem Machine { get; set; }
        public LocationViewItem[] Locations { get; set; }
    }

    public class AlertLayerPivotViewItem
    {
        public string ID { get; set; }
        public string Caption { get; set; }
        public string Name { get; set; }
        public DataTypes DataType { get; set; }
        public string DefaultValue { get; set; }
        public string ParameterValue { get; set; }
        public QueryParameterDisplayStyles DisplayStyle { get; set; }
        public string LookupDatasourceID { get; set; }
        public bool DisplayCaptionField { get; set; }
        public bool IsField { get; set; }
        public bool IsAllAllowed { get; set; }
        public bool MutipleSelect { get; set; }
        public bool IsCriteriaSQL { get; set; }
    }
}
