12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using Comal.Classes;
- using InABox.Core;
- using Xamarin.Forms;
- namespace comal.timesheets
- {
- public class AssignmentListDataModel : ListDataModel<Assignment, AssignmentListDataModelItem>
- {
- public override Columns<Assignment> Columns => new Columns<Assignment>(x => x.ID)
- .Add(x=>x.Number)
- .Add(x=>x.Title)
- .Add(x=>x.Description)
- .Add(x=>x.Date)
- .Add(x=>x.Start)
- .Add(x=>x.Finish)
- .Add(x=>x.ActivityLink.Color)
- .Add(x=>x.EmployeeLink.ID)
- .Add(x=>x.JobLink.ID)
- .Add(x=>x.JobLink.JobNumber)
- .Add(x=>x.JobLink.Name)
- .Add(x=>x.Task.ID)
- .Add(x=>x.Task.Number)
- .Add(x=>x.Task.Title)
- .Add(x=>x.Completed);
-
-
-
- }
-
- public class AssignmentListDataModelItem : CoreDataModelItem
- {
-
- public Guid Id => Row.Get<Assignment, Guid>(c => c.ID);
- public int Number => Row.Get<Assignment, int>(c => c.Number);
-
- public Guid EmployeeId => Row.Get<Assignment, Guid>(c => c.EmployeeLink.ID);
-
- public Guid JobID => Row.Get<Assignment, Guid>(c => c.JobLink.ID);
- public string JobNumber => Row.Get<Assignment, String>(c => c.JobLink.JobNumber);
- public string JobName => Row.Get<Assignment, String>(c => c.JobLink.Name);
-
- public Guid TaskID => Row.Get<Assignment, Guid>(c => c.Task.ID);
- public int TaskNumber => Row.Get<Assignment, int>(c => c.Task.Number);
- public string TaskName => Row.Get<Assignment, String>(c => c.Task.Title);
-
- public String Subject => string.Format("{0}{1} {2}",
- Row.Get<Assignment, int>(c => c.Number),
- Row.Get<Assignment,Guid>(c=>c.JobLink.ID) != Guid.Empty
- ? $"({Row.Get<Assignment, String>(c => c.JobLink.JobNumber)})"
- : "",
- Row.Get<Assignment, String>(c => c.Title));
-
- public string Notes => Row.Get<Assignment, String>(c => c.Description);
-
- public DateTime StartTime =>
- Row.Get<Assignment, DateTime>(c => c.Date).Add(Row.Get<Assignment, TimeSpan>(c => c.Start));
- public DateTime EndTime =>
- Row.Get<Assignment, DateTime>(c => c.Date).Add(Row.Get<Assignment, TimeSpan>(c => c.Finish));
- public bool Completed => !Row.Get<Assignment, DateTime>(c => c.Completed).IsEmpty();
- public Color Color
- {
- get
- {
- var color = Row.Get<Assignment, String>(c => c.ActivityLink.Color);
- return !String.IsNullOrWhiteSpace(color)
- ? Color.FromHex(color)
- : Color.Silver;
- }
- set { Row.Set<Assignment, String>(c => c.ActivityLink.Color, value.ToHex()); }
- }
- public Color TextColor => Color.Black;
- public ObservableCollection<object> ResourceIds => new ObservableCollection<object>() { Row.Get<Assignment, Guid>(c => c.EmployeeLink.ID) };
- }
- }
|