using System; using System.Linq; using Comal.Classes; using InABox.Mobile; using Xamarin.Forms; namespace PRS.Mobile { public class JobShell : Shell, ILookupShell { protected override void ConfigureColumns(ShellColumns columns) { columns .Map(nameof(JobNumber), x => x.JobNumber) .Map(nameof(Name), x => x.Name) .Map(nameof(Status), x => x.JobStatus.Description) .Map(nameof(Active), x=>x.JobStatus.Active) .Map(nameof(_color), x => x.Color) .Map(nameof(_latitude), x => x.SiteAddress.Location.Latitude) .Map(nameof(_longitude), x => x.SiteAddress.Location.Longitude) .Map(nameof(Notes), x => x.Notes) .Map(nameof(OpenAssignments), x => x.OpenAssignments) .Map(nameof(Street), x=>x.SiteAddress.Street) .Map(nameof(City), x=>x.SiteAddress.City) .Map(nameof(PostCode), x=>x.SiteAddress.PostCode) .Map(nameof(ContactID), x=>x.Contact.ID) .Map(nameof(ContactName), x=>x.Contact.Name); } public string Name => Get(); public string JobNumber => Get(); public string[] Notes => Get(); public Guid ContactID => Get(); public String ContactName => Get(); public string Street => Get(); public string City => Get(); public string PostCode => Get(); private double _latitude => Get(); private double _longitude => Get(); public InABox.Core.Location Location => new InABox.Core.Location() { Latitude = _latitude, Longitude = _longitude }; public int OpenAssignments => Get(); public String Status => Get(); public bool Active => Get(); private String _color => Get(); public Color Color => Color.FromHex(_color); // Calculated Fields public string DisplayName => ID.Equals(Guid.Empty) ? "" : $"{JobNumber}: {Name}"; // ILookupShell Wrapper public String LookupCode => JobNumber; public String LookupDescription => Name; public bool LookupSelected { get; set; } } }