Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using Perform.Common.Core.Enums;
- using Perform.Common.Core.Helpers;
- using Perform.Common.Core.Helpers.Tokenization;
- namespace Neogov.PE.Platform.Providers.Notifications.Models.Content
- {
- public class TaskReminderNotificationContent : IContentModel<TaskReminderNotificationContent>
- {
- public ITaskReminderNotification NotificationContent { get; set; }
- public int EmployerId { get; set; }
- public string RecipientRole { get; set; }
- public string RecipientFullName { get; set; }
- public long? ParentEvaluationId { get; set; }
- protected string Subject { get; set; }
- protected string TaskAssigneeName { get; set; }
- protected string PerformUrl { get; set; }
- protected string BrandName { get; set; }
- public string EmployeeName { get; set; }
- protected string EvaluationType { get; set; }
- protected string EvaluationName { get; set; }
- protected DateTime EvaluationDueDate { get; set; }
- protected DateTime TaskDueDate { get; set; }
- protected string TaskSubject { get; set; }
- public long TaskId { get; set; }
- protected string TaskDueOrOverdue { get; set; }
- protected string TaskPriority { get; set; }
- protected string TaskStatus { get; set; }
- protected string TaskComment { get; set; }
- protected string TaskRecurrence { get; private set; }
- public bool IsRecurringTask { get; set; }
- public StepType TaskType { get; set; }
- protected string TaskUrl { get; set; }
- protected string TaskName { get; set; }
- protected string TargetEmployeeDepartment { get; private set; }
- protected string TargetEmployeeDivision { get; private set; }
- protected string TargetEmployeePosition { get; private set; }
- protected bool IsAddEditContentTask { get; set; }
- protected string AddEditContentUrl { get; set; }
- public void Build(ModelBuilder builder)
- {
- var task = builder.GetTask(NotificationContent.TaskID, this.EmployerId);
- if (task == null)
- {
- throw new Exception($"Task with ID {NotificationContent.TaskID} for EmployerId {this.EmployerId} was not found");
- }
- this.TaskId = NotificationContent.TaskID;
- this.Subject = NotificationContent.Subject;
- this.EvaluationType = NotificationContent.EvaluationType;
- this.PerformUrl = NotificationContent.PeUrl;
- this.EmployeeName = NotificationContent.EvaluationEmployeeName;
- this.EvaluationName = NotificationContent.EvaluationName;
- this.EvaluationDueDate = NotificationContent.EvaluationDueDate;
- this.BrandName = NotificationContent.Brand.Name;
- this.TaskSubject = NotificationContent.TaskSubject;
- this.TaskDueOrOverdue = NotificationContent.DueOrOverdueString;
- this.TaskComment = NotificationContent.Comment;
- this.TaskDueDate = NotificationContent.TaskDueDate;
- this.TaskPriority = builder.TaskPriorityDisplay(NotificationContent.Priority);
- this.TaskStatus = builder.TaskStatusDisplay(NotificationContent.Status);
- this.TaskRecurrence = builder.GetTaskRecurrance(NotificationContent.TaskID, NotificationContent.EmployerId);
- this.IsRecurringTask = this.TaskRecurrence != null;
- this.TaskUrl = task != null ? builder.BuildTaskUrl(task, this.EmployerId).ToString() : "";
- this.TaskType = NotificationContent.StepType;
- this.TaskName = task.Title;
- if (this.ParentEvaluationId.HasValue)
- {
- var evaluation = builder.GetEvaluation(EmployerId, (int) this.ParentEvaluationId.Value);
- this.TargetEmployeePosition = evaluation.Position;
- this.TargetEmployeeDivision = evaluation.Division;
- this.TargetEmployeeDepartment = evaluation.Department;
- }
- this.IsAddEditContentTask = this.TaskType.IsAddEditContentActivity();
- this.AddEditContentUrl = this.ParentEvaluationId.HasValue ? builder.BuildAddEditContentUrl(EmployerId, ParentEvaluationId.Value, task.Id) : "";
- }
- public TaskReminderNotificationContent ProcessForRecipient(Recipient recipient)
- {
- this.TaskAssigneeName = this.RecipientFullName;
- return this;
- }
- public IEnumerable<IToken<TaskReminderNotificationContent>> GetTokens(int employerId)
- {
- yield return this.MakeToken(e => e.RecipientRole, "Recipient role");
- yield return this.MakeToken(e => e.RecipientFullName, "Recipient Full Name");
- yield return this.MakeToken(e => e.Subject);
- yield return this.MakeToken(e => e.TaskAssigneeName, "Task Assignee name");
- yield return this.MakeToken(e => e.PerformUrl, "Perform URL");
- yield return this.MakeToken("AgencyName", e => e.BrandName, "Agency name");
- yield return this.MakeToken(e => e.EmployeeName, "Employee Name");
- yield return this.MakeToken(e => e.EvaluationType, "Evaluation Type");
- yield return this.MakeToken(e => e.EvaluationName, "Evaluation Name");
- yield return this.MakeToken("EvaluationDueDate",e => e.EvaluationDueDate.ToShortDateString(), "Evaluation Due Date");
- yield return this.MakeToken(e => e.TaskSubject, "Task subject");
- yield return this.MakeToken(e => e.TaskDueOrOverdue, "Task Due or overdue String");
- yield return this.MakeToken(e => e.TaskPriority, "Task priority");
- yield return this.MakeToken(e => e.TaskStatus, "Task status");
- yield return this.MakeToken(e => e.TaskComment, "Task comment");
- yield return this.MakeToken("TaskDueDate",e => e.TaskDueDate.ToShortDateString(), "Task due Date");
- yield return this.MakeToken("TaskName",e => e.TaskName, "Task name");
- if (this.ParentEvaluationId.HasValue)
- {
- yield return this.MakeToken("TargetEmployeePosition", e => e.TargetEmployeePosition, "Target Employee Position");
- yield return this.MakeToken("TargetEmployeeDivision", e => e.TargetEmployeeDivision, "Target Employee Division");
- yield return this.MakeToken("TargetEmployeeDepartment", e => e.TargetEmployeeDepartment, "Target Employee Department");
- }
- if (this.IsRecurringTask)
- {
- yield return this.MakeToken(e => e.TaskRecurrence, "Task Recurrance");
- if (this.TaskType == StepType.CheckIn)
- yield return this.MakeToken("CheckInUrl", e => e.TaskUrl, "Checkin Url");
- }
- if (this.IsAddEditContentTask)
- {
- yield return this.MakeToken("TaskURL", e => e.AddEditContentUrl, "Add Edit Content Url");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement