LeaveRequestStore.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Comal.Classes;
  7. using InABox.Core;
  8. namespace Comal.Stores
  9. {
  10. internal class LeaveRequestStore : BaseStore<LeaveRequest>
  11. {
  12. protected override void OnSave(LeaveRequest entity, ref string auditnote)
  13. {
  14. base.OnSave(entity, ref auditnote);
  15. if (entity.HasOriginalValue(c => c.Status))
  16. NotifyEmployee(
  17. entity,
  18. x => x.EmployeeLink.ID,
  19. e => e.HasOriginalValue(x => x.Status),
  20. e => string.Format("Leave Request {0}", e.Status),
  21. e =>
  22. {
  23. var sb = new StringBuilder();
  24. sb.AppendLine(string.Format(
  25. "Your Leave Request submitted {0:dd MMM yyy} for {1:dd MMM yy} - {2:dd MMM yy} has changed from {3} to {4}.",
  26. e.Created,
  27. e.From,
  28. e.To,
  29. e.GetOriginalValue(c => c.Status),
  30. e.Status
  31. ));
  32. if (!string.IsNullOrWhiteSpace(e.StatusNotes))
  33. sb.AppendLine(string.Format("\nNotes:\n{0}", e.StatusNotes?.Trim()));
  34. return sb.ToString();
  35. }
  36. );
  37. }
  38. }
  39. }