private dataAccess.Entity.Cost BuildCost(Guid costId, CostUser[] costUsers, dataAccess.Entity.Project project) { const string agencyName = "Saatchi"; const string brandName = "P&G"; const string costNumber = "P101"; const CostStages costStageName = CostStages.OriginalEstimate; var cost = new dataAccess.Entity.Cost { Parent = new AbstractType() }; var costOwner = costUsers[0]; var latestRevision = new CostStageRevision(); var costStage = new CostStage(); var brand = new dataAccess.Entity.Brand(); var agency = new dataAccess.Entity.Agency(); cost.CostNumber = costNumber; cost.LatestCostStageRevision = latestRevision; cost.Project = project; cost.Parent.Agency = agency; costOwner.Agency = agency; costOwner.Id = Guid.NewGuid(); latestRevision.CostStage = costStage; agency.Name = agencyName; brand.Name = brandName; cost.Id = costId; costStage.Name = costStageName.ToString(); latestRevision.Id = Guid.NewGuid(); return(cost); }
internal async Task <IEnumerable <EmailNotificationMessage <CostNotificationObject> > > Build(dataAccess.Entity.Cost cost, CostNotificationUsers costUsers, string requestedByName, CostStageRevision costStageRevision, DateTime timestamp) { var notifications = new List <EmailNotificationMessage <CostNotificationObject> >(); //Admin Notification - one notification object for all admins var adminIds = costUsers.ClientAdmins.Select(x => x.GdamUserId).ToList(); var adminNotification = new EmailNotificationMessage <CostNotificationObject>(core.Constants.EmailNotificationActionType.ReopenRequested, adminIds); AddSharedTo(adminNotification); MapEmailNotificationObject(adminNotification.Object, cost, costUsers.CostOwner); PopulateOtherFields(adminNotification, string.Empty, timestamp, cost.Id, costStageRevision.Id); await PopulateMetadata(adminNotification.Object, cost.Id); adminNotification.Object.Approver.Name = requestedByName; notifications.Add(adminNotification); await AddFinanceManagerNotification(core.Constants.EmailNotificationActionType.CostStatus, cost, costUsers, costStageRevision, timestamp, notifications); return(notifications); }
private async Task BuildPendingTechnicalApprovalNotification(List <EmailNotificationMessage <CostNotificationObject> > notifications, List <Approval> approvals, dataAccess.Entity.Cost cost, CostNotificationUsers costUsers, CostUser costOwner, CostStageRevision costStageRevision, DateTime timestamp) { const string actionType = core.Constants.EmailNotificationActionType.TechnicalApproverSendReminder; var technicalApprovals = approvals.Where(a => a.Type == ApprovalType.IPM).ToArray(); foreach (var technicalApproval in technicalApprovals) { foreach (var approvalMember in technicalApproval.ApprovalMembers) { //Send notifications to Technical Approver var approvalCostUser = approvalMember.CostUser; var technicalApproverNotification = new EmailNotificationMessage <CostNotificationObject>(actionType, approvalCostUser.GdamUserId); AddSharedTo(technicalApproverNotification); MapEmailNotificationObject(technicalApproverNotification.Object, cost, costOwner, approvalCostUser); PopulateOtherFields(technicalApproverNotification, core.Constants.EmailNotificationParents.TechnicalApprover, timestamp, cost.Id, costStageRevision.Id, approvalCostUser); await PopulateMetadata(technicalApproverNotification.Object, cost.Id); notifications.Add(technicalApproverNotification); } } }
internal async Task <IEnumerable <EmailNotificationMessage <CostNotificationObject> > > Build(dataAccess.Entity.Cost cost, CostNotificationUsers costUsers, CostStageRevision costStageRevision, DateTime timestamp) { var notifications = new List <EmailNotificationMessage <CostNotificationObject> >(); var approvals = await _approvalService.GetApprovalsByCostStageRevisionId(costStageRevision.Id); if (approvals == null) { //No approvals set return(notifications); } await BuildPendingTechnicalApprovalNotification(notifications, approvals, cost, costUsers, costUsers.CostOwner, costStageRevision, timestamp); return(notifications); }
internal async Task <IEnumerable <EmailNotificationMessage <CostNotificationObject> > > Build(dataAccess.Entity.Cost cost, CostNotificationUsers costUsers, CostStageRevision costStageRevision, DateTime timestamp) { var notifications = new List <EmailNotificationMessage <CostNotificationObject> >(); var approvals = _approvalService.GetApprovalsByCostStageRevisionId(costStageRevision.Id).Result; const string actionType = core.Constants.EmailNotificationActionType.TechnicalApproverAssigned; if (approvals == null) { //No approvals set return(notifications); } var costOwner = costUsers.CostOwner; var technicalApprovals = approvals.Where(a => a.Type == ApprovalType.IPM).ToArray(); foreach (var technicalApproval in technicalApprovals) { foreach (var approvalMember in technicalApproval.ApprovalMembers) { //Send notifications to Technical Approver var approvalCostUser = approvalMember.CostUser; var technicalApproverNotification = new EmailNotificationMessage <CostNotificationObject>(actionType, approvalCostUser.GdamUserId); AddSharedTo(technicalApproverNotification); MapEmailNotificationObject(technicalApproverNotification.Object, cost, costOwner, approvalCostUser); PopulateOtherFields(technicalApproverNotification, core.Constants.EmailNotificationParents.TechnicalApprover, timestamp, cost.Id, costStageRevision.Id, approvalCostUser); await PopulateMetadata(technicalApproverNotification.Object, cost.Id); notifications.Add(technicalApproverNotification); //Insurance User if (ShouldNotifyInsuranceUsers(costUsers)) { var insuranceUserNotification = new EmailNotificationMessage <CostNotificationObject>(actionType, costUsers.InsuranceUsers); AddSharedTo(insuranceUserNotification); MapEmailNotificationObject(insuranceUserNotification.Object, cost, costOwner, approvalCostUser); PopulateOtherFields(insuranceUserNotification, core.Constants.EmailNotificationParents.InsuranceUser, timestamp, cost.Id, costStageRevision.Id, approvalCostUser); await PopulateMetadata(insuranceUserNotification.Object, cost.Id); notifications.Add(insuranceUserNotification); } } } await AddFinanceManagerNotification(actionType, cost, costUsers, costStageRevision, timestamp, notifications); return(notifications); }
internal async Task <IEnumerable <EmailNotificationMessage <CostNotificationObject> > > Build(dataAccess.Entity.Cost cost, CostNotificationUsers costUsers, CostStageRevision costStageRevision, DateTime timestamp) { var notifications = new List <EmailNotificationMessage <CostNotificationObject> >(); //Cost Owner var costOwner = costUsers.CostOwner; var costOwnerNotification = new EmailNotificationMessage <CostNotificationObject>( core.Constants.EmailNotificationActionType.Submitted, costOwner.GdamUserId); AddSharedTo(costOwnerNotification); MapEmailNotificationObject(costOwnerNotification.Object, cost, costOwner); PopulateOtherFields(costOwnerNotification, core.Constants.EmailNotificationParents.CostOwner, timestamp, cost.Id, costStageRevision.Id); await PopulateMetadata(costOwnerNotification.Object, cost.Id); notifications.Add(costOwnerNotification); return(notifications); }
private async Task BuildPendingBrandApprovalNotification(List <EmailNotificationMessage <CostNotificationObject> > notifications, List <Approval> approvals, dataAccess.Entity.Cost cost, CostUser costOwner, Guid costStageRevisionId, DateTime timestamp) { var brandApprovals = approvals.Where(a => a.Type == ApprovalType.Brand).ToArray(); bool isCyclone = IsNorthAmericanCycloneAgency(costOwner.Agency); string actionType = core.Constants.EmailNotificationActionType.BrandApproverSendReminder; foreach (var brandApproval in brandApprovals) { if (isCyclone) { var parent = core.Constants.EmailNotificationParents.BrandApprover; //Send notification to Brand Approver in the Platform for North American Cyclone agencies to every approval member foreach (var approvalMember in brandApproval.ApprovalMembers) { var brandApproverNotification = new EmailNotificationMessage <CostNotificationObject>(actionType, approvalMember.CostUser.GdamUserId); AddSharedTo(brandApproverNotification); MapEmailNotificationObject(brandApproverNotification.Object, cost, costOwner, approvalMember.CostUser); PopulateOtherFields(brandApproverNotification, parent, timestamp, cost.Id, costStageRevisionId); await PopulateMetadata(brandApproverNotification.Object, cost.Id); notifications.Add(brandApproverNotification); } } else { //Send one email to Cost Owner for approval in Coupa var parent = core.Constants.EmailNotificationParents.Coupa; var brandApproverNotification = new EmailNotificationMessage <CostNotificationObject>(actionType, costOwner.GdamUserId); AddSharedTo(brandApproverNotification); MapEmailNotificationObject(brandApproverNotification.Object, cost, costOwner, costOwner); PopulateOtherFields(brandApproverNotification, parent, timestamp, cost.Id, costStageRevisionId); await PopulateMetadata(brandApproverNotification.Object, cost.Id); notifications.Add(brandApproverNotification); } } }
internal async Task <IEnumerable <EmailNotificationMessage <CostNotificationObject> > > Build(dataAccess.Entity.Cost cost, CostNotificationUsers costUsers, CostStageRevision costStageRevision, DateTime timestamp) { var notifications = new List <EmailNotificationMessage <CostNotificationObject> >(); //Build PendingBrandApproval notifications var approvals = _approvalService.GetApprovalsByCostStageRevisionId(costStageRevision.Id).Result; if (approvals != null) { var costOwner = costUsers.CostOwner; await BuildPendingBrandApprovalNotification(notifications, approvals, cost, costOwner, costStageRevision.Id, timestamp); } return(notifications); }
internal async Task <IEnumerable <EmailNotificationMessage <CostNotificationObject> > > Build(dataAccess.Entity.Cost cost, CostNotificationUsers costUsers, string approverName, string approvalType, string comments, CostStageRevision costStageRevision, DateTime timestamp) { var notifications = new List <EmailNotificationMessage <CostNotificationObject> >(); const string actionType = core.Constants.EmailNotificationActionType.Rejected; //Cost Owner var costOwner = costUsers.CostOwner; var recipients = new List <string> { costOwner.GdamUserId }; recipients.AddRange(costUsers.Watchers); var costOwnerNotification = new EmailNotificationMessage <CostNotificationObject>(actionType, recipients); AddSharedTo(costOwnerNotification); MapEmailNotificationObject(costOwnerNotification.Object, cost, costOwner); PopulateOtherFields(costOwnerNotification, core.Constants.EmailNotificationParents.CostOwner, timestamp, cost.Id, costStageRevision.Id); await PopulateMetadata(costOwnerNotification.Object, cost.Id); var obj = costOwnerNotification.Object; var approver = obj.Approver; approver.Name = approverName; approver.Type = approvalType; obj.Comments = comments; notifications.Add(costOwnerNotification); if (ShouldNotifyInsuranceUsers(costUsers)) { var insuranceUserNotification = new EmailNotificationMessage <CostNotificationObject>(actionType, costUsers.InsuranceUsers); AddSharedTo(insuranceUserNotification); MapEmailNotificationObject(insuranceUserNotification.Object, cost, costOwner); PopulateOtherFields(insuranceUserNotification, core.Constants.EmailNotificationParents.InsuranceUser, timestamp, cost.Id, costStageRevision.Id); await PopulateMetadata(insuranceUserNotification.Object, cost.Id); obj = insuranceUserNotification.Object; approver = obj.Approver; approver.Name = approverName; approver.Type = approvalType; obj.Comments = comments; notifications.Add(insuranceUserNotification); } await AddFinanceManagerNotification(actionType, cost, costUsers, costStageRevision, timestamp, notifications); return(notifications); }