示例#1
0
        public async Task sendStatuschangeNotification(string vPartnerUserId, int userid, string previousStatus, string currentStatus)
        {
            string date = DateTime.Now.ToString("yyyy-MM-dd");
            var    time = DateTime.Now.ToLongTimeString();
            PartnerNotificationsLog PartnerNotificationsLogReq = new PartnerNotificationsLog();

            try
            {
                using (var client = new HttpClient())
                {
                    object obj = new
                    {
                        UserObjectId   = vPartnerUserId,
                        Date           = date,
                        Time           = time,
                        PreviousStatus = previousStatus,
                        CurrentStatus  = currentStatus
                    };
                    List <GeneralSetting> i2cSettings = await GetGeneralSettings();

                    var url     = i2cSettings[0].Value;
                    var hostURL = new Uri($"" + url + "/" + SodexoBiteNotification.StatusChange);

                    string myJSON = Newtonsoft.Json.JsonConvert.SerializeObject(obj);
                    PartnerNotificationsLogReq = await _partnerNotificationsLogRepository.PartnerNotificationsLogRequest("ChangeStatus", hostURL.ToString(), myJSON, userid);

                    HttpContent stringContent = new StringContent(myJSON);
                    stringContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
                    var result = await client.PostAsync(hostURL, stringContent);

                    PartnerNotificationsLogReq.Status = result.StatusCode.ToString();
                    var content = await result.Content.ReadAsStringAsync();

                    await _partnerNotificationsLogRepository.PartnerNotificationsLogResponse(PartnerNotificationsLogReq, content);
                }
            }
            catch (Exception ex)
            {
                PartnerNotificationsLogReq.Status = "Error";
                await _partnerNotificationsLogRepository.PartnerNotificationsLogResponse(PartnerNotificationsLogReq, ex.Message);
            }
        }
示例#2
0
        public async Task sendReloadSetUpNotification(string benefactor, string vPartnerUserId, int userid, decimal vAmountAdded, decimal ThresholdAmount)
        {
            PartnerNotificationsLog PartnerNotificationsLogReq = new PartnerNotificationsLog();

            try
            {
                using (var client = new HttpClient())
                {
                    object obj = new
                    {
                        UserObjectId        = vPartnerUserId,
                        Lowbalancethreshold = ThresholdAmount,
                        BenefactorName      = benefactor,
                        Addvalueamount      = vAmountAdded
                    };
                    List <GeneralSetting> i2cSettings = await GetGeneralSettings();

                    var url     = i2cSettings[0].Value;
                    var hostURL = new Uri($"" + url + "/" + SodexoBiteNotification.ReloadSetUp);

                    string myJSON = Newtonsoft.Json.JsonConvert.SerializeObject(obj);
                    PartnerNotificationsLogReq = await _partnerNotificationsLogRepository.PartnerNotificationsLogRequest("AddUpdateReloadRules", hostURL.ToString(), myJSON, userid);

                    HttpContent stringContent = new StringContent(myJSON);
                    stringContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");


                    // var content = new StringContent(myJSON.ToString(), Encoding.UTF8, "application/json");
                    var result = await client.PostAsync(hostURL, stringContent);

                    PartnerNotificationsLogReq.Status = result.StatusCode.ToString();
                    var content = await result.Content.ReadAsStringAsync();

                    await _partnerNotificationsLogRepository.PartnerNotificationsLogResponse(PartnerNotificationsLogReq, content);
                }
            }
            catch (Exception ex)
            {
                PartnerNotificationsLogReq.Status = "Error";
                await _partnerNotificationsLogRepository.PartnerNotificationsLogResponse(PartnerNotificationsLogReq, ex.Message);
            }
        }