Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.96 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using Perform.Common.Core.Enums;
  4. using Perform.Common.Core.Helpers;
  5. using Perform.Common.Core.Helpers.Tokenization;
  6.  
  7. namespace Neogov.PE.Platform.Providers.Notifications.Models.Content
  8. {
  9. public class TaskReminderNotificationContent : IContentModel<TaskReminderNotificationContent>
  10. {
  11. public ITaskReminderNotification NotificationContent { get; set; }
  12.  
  13. public int EmployerId { get; set; }
  14. public string RecipientRole { get; set; }
  15. public string RecipientFullName { get; set; }
  16. public long? ParentEvaluationId { get; set; }
  17.  
  18.  
  19. protected string Subject { get; set; }
  20. protected string TaskAssigneeName { get; set; }
  21. protected string PerformUrl { get; set; }
  22. protected string BrandName { get; set; }
  23. public string EmployeeName { get; set; }
  24. protected string EvaluationType { get; set; }
  25. protected string EvaluationName { get; set; }
  26. protected DateTime EvaluationDueDate { get; set; }
  27. protected DateTime TaskDueDate { get; set; }
  28. protected string TaskSubject { get; set; }
  29. public long TaskId { get; set; }
  30. protected string TaskDueOrOverdue { get; set; }
  31. protected string TaskPriority { get; set; }
  32. protected string TaskStatus { get; set; }
  33. protected string TaskComment { get; set; }
  34. protected string TaskRecurrence { get; private set; }
  35. public bool IsRecurringTask { get; set; }
  36. public StepType TaskType { get; set; }
  37. protected string TaskUrl { get; set; }
  38. protected string TaskName { get; set; }
  39. protected string TargetEmployeeDepartment { get; private set; }
  40. protected string TargetEmployeeDivision { get; private set; }
  41. protected string TargetEmployeePosition { get; private set; }
  42. protected bool IsAddEditContentTask { get; set; }
  43. protected string AddEditContentUrl { get; set; }
  44.  
  45.  
  46. public void Build(ModelBuilder builder)
  47. {
  48. var task = builder.GetTask(NotificationContent.TaskID, this.EmployerId);
  49. if (task == null)
  50. {
  51. throw new Exception($"Task with ID {NotificationContent.TaskID} for EmployerId {this.EmployerId} was not found");
  52. }
  53.  
  54. this.TaskId = NotificationContent.TaskID;
  55. this.Subject = NotificationContent.Subject;
  56. this.EvaluationType = NotificationContent.EvaluationType;
  57. this.PerformUrl = NotificationContent.PeUrl;
  58. this.EmployeeName = NotificationContent.EvaluationEmployeeName;
  59. this.EvaluationName = NotificationContent.EvaluationName;
  60. this.EvaluationDueDate = NotificationContent.EvaluationDueDate;
  61. this.BrandName = NotificationContent.Brand.Name;
  62. this.TaskSubject = NotificationContent.TaskSubject;
  63. this.TaskDueOrOverdue = NotificationContent.DueOrOverdueString;
  64. this.TaskComment = NotificationContent.Comment;
  65. this.TaskDueDate = NotificationContent.TaskDueDate;
  66. this.TaskPriority = builder.TaskPriorityDisplay(NotificationContent.Priority);
  67. this.TaskStatus = builder.TaskStatusDisplay(NotificationContent.Status);
  68. this.TaskRecurrence = builder.GetTaskRecurrance(NotificationContent.TaskID, NotificationContent.EmployerId);
  69. this.IsRecurringTask = this.TaskRecurrence != null;
  70. this.TaskUrl = task != null ? builder.BuildTaskUrl(task, this.EmployerId).ToString() : "";
  71. this.TaskType = NotificationContent.StepType;
  72. this.TaskName = task.Title;
  73. if (this.ParentEvaluationId.HasValue)
  74. {
  75. var evaluation = builder.GetEvaluation(EmployerId, (int) this.ParentEvaluationId.Value);
  76. this.TargetEmployeePosition = evaluation.Position;
  77. this.TargetEmployeeDivision = evaluation.Division;
  78. this.TargetEmployeeDepartment = evaluation.Department;
  79.  
  80. }
  81. this.IsAddEditContentTask = this.TaskType.IsAddEditContentActivity();
  82. this.AddEditContentUrl = this.ParentEvaluationId.HasValue ? builder.BuildAddEditContentUrl(EmployerId, ParentEvaluationId.Value, task.Id) : "";
  83. }
  84.  
  85. public TaskReminderNotificationContent ProcessForRecipient(Recipient recipient)
  86. {
  87. this.TaskAssigneeName = this.RecipientFullName;
  88. return this;
  89. }
  90.  
  91. public IEnumerable<IToken<TaskReminderNotificationContent>> GetTokens(int employerId)
  92. {
  93. yield return this.MakeToken(e => e.RecipientRole, "Recipient role");
  94. yield return this.MakeToken(e => e.RecipientFullName, "Recipient Full Name");
  95. yield return this.MakeToken(e => e.Subject);
  96. yield return this.MakeToken(e => e.TaskAssigneeName, "Task Assignee name");
  97. yield return this.MakeToken(e => e.PerformUrl, "Perform URL");
  98. yield return this.MakeToken("AgencyName", e => e.BrandName, "Agency name");
  99. yield return this.MakeToken(e => e.EmployeeName, "Employee Name");
  100. yield return this.MakeToken(e => e.EvaluationType, "Evaluation Type");
  101. yield return this.MakeToken(e => e.EvaluationName, "Evaluation Name");
  102. yield return this.MakeToken("EvaluationDueDate",e => e.EvaluationDueDate.ToShortDateString(), "Evaluation Due Date");
  103. yield return this.MakeToken(e => e.TaskSubject, "Task subject");
  104. yield return this.MakeToken(e => e.TaskDueOrOverdue, "Task Due or overdue String");
  105. yield return this.MakeToken(e => e.TaskPriority, "Task priority");
  106. yield return this.MakeToken(e => e.TaskStatus, "Task status");
  107. yield return this.MakeToken(e => e.TaskComment, "Task comment");
  108. yield return this.MakeToken("TaskDueDate",e => e.TaskDueDate.ToShortDateString(), "Task due Date");
  109. yield return this.MakeToken("TaskName",e => e.TaskName, "Task name");
  110. if (this.ParentEvaluationId.HasValue)
  111. {
  112. yield return this.MakeToken("TargetEmployeePosition", e => e.TargetEmployeePosition, "Target Employee Position");
  113. yield return this.MakeToken("TargetEmployeeDivision", e => e.TargetEmployeeDivision, "Target Employee Division");
  114. yield return this.MakeToken("TargetEmployeeDepartment", e => e.TargetEmployeeDepartment, "Target Employee Department");
  115. }
  116. if (this.IsRecurringTask)
  117. {
  118. yield return this.MakeToken(e => e.TaskRecurrence, "Task Recurrance");
  119. if (this.TaskType == StepType.CheckIn)
  120. yield return this.MakeToken("CheckInUrl", e => e.TaskUrl, "Checkin Url");
  121. }
  122. if (this.IsAddEditContentTask)
  123. {
  124. yield return this.MakeToken("TaskURL", e => e.AddEditContentUrl, "Add Edit Content Url");
  125. }
  126. }
  127. }
  128. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement