Example #1
0
        public string AddMessageToEmailQueue(BO.EmailMessage message)
        {
            try
            {
                //Set AccessToken to client header
                HttpClient client = new HttpClient();
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                client.DefaultRequestHeaders.Add("Authorization", AccessToken);
                client.BaseAddress = new Uri(NotificationServiceBaseURL);

                //HttpResponseMessage response = client.PostAsJsonAsync("EMail/AddMessageToQueue", message).Result;
                HttpResponseMessage response = client.PostAsJsonAsync("EMail/SendMessageInstantly", message).Result;

                response.EnsureSuccessStatusCode();
                var status = response.Content.ReadAsStringAsync().Result;


                //TEMP
                //HttpResponseMessage response2 = client.PostAsJsonAsync("EMail/SendMessageInstantly", message).Result;


                return(status);
            }
            catch (Exception e)
            {
                return(e.Message);
            }
        }
Example #2
0
        public BO.Enums.PreferedModeOfComunication SendEmailAndSms(string userName, int companyId, BO.EmailMessage emailData)
        {
            try
            {
                BO.Enums.PreferedModeOfComunication predferredModewOfCommunication = BO.Enums.PreferedModeOfComunication.Email; // GetModeOfComunication(userName, companyId);

                if (predferredModewOfCommunication == BO.Enums.PreferedModeOfComunication.Email)
                {
                    AddMessageToEmailQueue(emailData);
                    return(BO.Enums.PreferedModeOfComunication.Email);
                }
                //else if (predferredModewOfCommunication == BO.Enums.PreferedModeOfComunication.SMS)
                //{
                //    AddMessageToSMSQueue(smsData);
                //    return BO.Enums.PreferedModeOfComunication.SMS;
                //}
                //else
                //{
                //    AddMessageToEmailQueue(emailData);
                //    AddMessageToSMSQueue(smsData);
                //    return BO.Enums.PreferedModeOfComunication.Both;

                //}
            }
            catch (Exception e)
            {
                return(BO.Enums.PreferedModeOfComunication.Both);
            }
            return(BO.Enums.PreferedModeOfComunication.Email);
        }