Esempio n. 1
0
        private IMessage GetMessage(CommunicationJobTypes communicationJobTypes)
        {
            switch (communicationJobTypes)
            {
            case CommunicationJobTypes.SendRegistrationChasers:
                return(new RegistrationChaserMessage(_connectUserService, _cosmosDbService, _emailConfig));

            case CommunicationJobTypes.SendNewTaskNotification:
                return(new TaskNotificationMessage(_connectUserService, _connectRequestService, _connectGroupService));

            case CommunicationJobTypes.RequestorTaskConfirmation:
                return(new RequestorTaskConfirmation(_connectRequestService, _connectGroupService, _connectAddressService, _linkRepository, _linkConfig, _sendGridConfig));

            case CommunicationJobTypes.SendTaskStateChangeUpdate:
                return(new TaskUpdateSimplifiedMessage(_connectRequestService, _connectUserService, _connectGroupService, _linkRepository, _linkConfig, _sendGridConfig, _connectAddressService));

            case CommunicationJobTypes.SendOpenTaskDigest:
                return(new DailyDigestMessage(_connectGroupService, _connectUserService, _connectRequestService, _emailConfig, _connectAddressService, _cosmosDbService));

            case CommunicationJobTypes.SendTaskReminder:
                return(new TaskReminderMessage(_connectRequestService, _connectUserService, _cosmosDbService));

            case CommunicationJobTypes.SendShiftReminder:
                return(new ShiftReminderMessage(_connectRequestService, _connectUserService, _connectAddressService, _linkRepository, _linkConfig));

            case CommunicationJobTypes.InterUserMessage:
                return(new InterUserMessage(_connectRequestService, _connectUserService));

            case CommunicationJobTypes.NewCredentials:
                return(new NewCredentialsMessage(_connectUserService, _connectGroupService));

            case CommunicationJobTypes.TaskDetail:
                return(new TaskDetailMessage(_connectGroupService, _connectUserService, _connectRequestService, _emailConfig, _cosmosDbService));

            case CommunicationJobTypes.SendNewRequestNotification:
                return(new NewRequestNotificationMessage(_connectRequestService, _connectAddressService, _connectUserService, _cosmosDbService, _emailConfig, _connectGroupService));

            case CommunicationJobTypes.NewTaskPendingApprovalNotification:
                return(new NewTaskPendingApprovalNotification(_connectRequestService, _connectGroupService, _connectUserService, _linkRepository, _linkConfig));

            case CommunicationJobTypes.GroupWelcome:
                return(new GroupWelcomeMessage(_connectGroupService, _connectUserService, _sendGridConfig));

            default:
                throw new Exception("Unknown Email Type");
            }
        }
Esempio n. 2
0
        public async Task <List <KeyValuePair <string, string> > > GetGroupEmailConfiguration(int groupId, CommunicationJobTypes communicationJobType)
        {
            GetGroupEmailConfigurationRequest request = new GetGroupEmailConfigurationRequest()
            {
                GroupId = groupId, CommunicationJob = new CommunicationJob()
                {
                    CommunicationJobType = communicationJobType
                }
            };
            string        json = JsonConvert.SerializeObject(request);
            StringContent data = new StringContent(json, Encoding.UTF8, "application/json");

            using (HttpResponseMessage response = await _httpClientWrapper.PostAsync(HttpClientConfigName.GroupService, "/api/GetGroupEmailConfiguration", data, CancellationToken.None).ConfigureAwait(false))
            {
                string jsonResponse = await response.Content.ReadAsStringAsync();

                var getJobsResponse = JsonConvert.DeserializeObject <ResponseWrapper <GetGroupEmailConfigurationResponse, GroupServiceErrorCode> >(jsonResponse);
                if (getJobsResponse.HasContent && getJobsResponse.IsSuccessful)
                {
                    return(getJobsResponse.Content.EmailConfigurations);
                }
                return(null);
            }
        }