TimesheetStore.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. using System;
  2. using Comal.Classes;
  3. namespace Comal.Stores
  4. {
  5. internal class TimesheetStore : BaseStore<TimeSheet>
  6. {
  7. protected override void BeforeSave(TimeSheet entity)
  8. {
  9. if (!entity.EmployeeLink.IsValid() && entity.EmployeeID != Guid.Empty)
  10. entity.EmployeeLink.ID = entity.EmployeeID;
  11. else if (entity.EmployeeLink.IsValid() && entity.EmployeeID == Guid.Empty)
  12. entity.EmployeeID = entity.EmployeeLink.ID;
  13. base.BeforeSave(entity);
  14. //UpdateAggregate<Job>(entity, entity.JobLink, Sum<Job>(t => t.ApprovedDuration, j => j.LabourHours));
  15. //UpdateAggregate<Invoice>(entity, entity.InvoiceLink, Sum<Invoice>(t => t.ApprovedDuration, i => i.LabourHours));
  16. }
  17. protected override void BeforeDelete(TimeSheet entity)
  18. {
  19. base.BeforeDelete(entity);
  20. //entity.JobLink.ID = Guid.Empty;
  21. //UpdateAggregate<Job>(entity, entity.JobLink, Sum<Job>(t => t.ApprovedDuration, j => j.LabourHours));
  22. //entity.InvoiceLink.ID = Guid.Empty;
  23. //UpdateAggregate<Invoice>(entity, entity.InvoiceLink, Sum<Invoice>(t => t.ApprovedDuration, i => i.LabourHours));
  24. }
  25. }
  26. }