コード例 #1
0
        public ResponsResult GetSMSList(SmsSearchModel model)
        {
            ResponsResult result = new ResponsResult();
            var           query  = base.Query <SmsInfo>();

            if (!string.IsNullOrEmpty(model.IP))
            {
                query = query.Where(t => t.Ip.Contains(model.IP));
            }
            if (!string.IsNullOrEmpty(model.Mobile))
            {
                query = query.Where(t => t.Mobile.Contains(model.Mobile));
            }
            if (model.StartDate.HasValue)
            {
                query = query.Where(t => t.CreateTime >= model.StartDate);
            }
            if (model.EndDate.HasValue)
            {
                query = query.Where(t => t.CreateTime <= model.EndDate);
            }
            result.Data        = query.OrderByDescending(t => t.CreateTime).Pages(model.PageIndex, model.PageSize, out int count).ToList();
            result.RecordCount = count;
            return(result);
        }
コード例 #2
0
 public ConfigurationModel()
 {
     AvailableLists             = new List <SelectListItem>();
     AvailableSenders           = new List <SelectListItem>();
     AvailableMessageTemplates  = new List <SelectListItem>();
     MessageTemplateSearchModel = new SendinBlueMessageTemplateSearchModel();
     SmsSearchModel             = new SmsSearchModel();
     AddSms = new SmsModel();
 }
コード例 #3
0
        public async Task <SmsSearchModel> GetSmses(SmsSearchModel model)
        {
            var url    = CRMApiUri + "/Sms/GetSmss?" + GetFilterString(model);
            var result = await GetOdataResultFromApi(url);

            var searchResultCount = 0;

            if (result.Count != null)
            {
                int.TryParse(result.Count.ToString(), out searchResultCount);
            }
            model.TotalRows = searchResultCount;
            model.SmsSearchResult.Clear();
            model.SmsSearchResult.AddRange(result.Items.Select(item => JsonConvert.DeserializeObject <SmsDto>(item.ToString())));
            return(model);
        }
コード例 #4
0
        private string GetFilterString(SmsSearchModel searchModel)
        {
            var filterString = string.Empty;

            if (searchModel != null)
            {
                if (!string.IsNullOrWhiteSpace(searchModel.FilterText))
                {
                    if (string.IsNullOrWhiteSpace(filterString))
                    {
                        filterString = ODataFilterConstant.Filter + $"contains(Forename,'{searchModel.FilterText}') eq true";
                    }
                    else
                    {
                        filterString += $" or contains(Forename,'{searchModel.FilterText}') eq true";
                    }
                    filterString += $" or contains(Surname,'{searchModel.FilterText}') eq true";
                }
                AddPageSizeNumberAndSortingInFilterString(searchModel, ref filterString);
            }
            return(filterString);
        }
コード例 #5
0
        public async Task <IActionResult> SMSList(SmsSearchModel searchModel)
        {
            var storeId = await _storeContext.GetActiveStoreScopeConfigurationAsync();

            //get message templates which are sending in SMS
            var allMessageTemplates = await _messageTemplateService.GetAllMessageTemplatesAsync(storeId);

            var messageTemplates = await allMessageTemplates

                                   .WhereAwait(async messageTemplate => await _genericAttributeService.GetAttributeAsync <bool>(messageTemplate, SendinblueDefaults.UseSmsAttribute))
                                   .ToPagedListAsync(searchModel);

            //prepare list model
            var model = await new SmsListModel().PrepareToGridAsync(searchModel, messageTemplates, () =>
            {
                return(messageTemplates.SelectAwait(async messageTemplate =>
                {
                    var phoneTypeID = await _genericAttributeService.GetAttributeAsync <int>(messageTemplate, SendinblueDefaults.PhoneTypeAttribute);

                    var smsModel = new SmsModel
                    {
                        Id = messageTemplate.Id,
                        MessageId = messageTemplate.Id,
                        Name = messageTemplate.Name,
                        PhoneTypeId = phoneTypeID,

                        Text = await _genericAttributeService.GetAttributeAsync <string>(messageTemplate, SendinblueDefaults.SmsTextAttribute)
                    };

                    if (storeId == 0)
                    {
                        if (storeId == 0 && messageTemplate.LimitedToStores)
                        {
                            var storeIds = await _storeMappingService.GetStoresIdsWithAccessAsync(messageTemplate);
                            var storeNames = (await _storeService.GetAllStoresAsync()).Where(store => storeIds.Contains(store.Id)).Select(store => store.Name);

                            smsModel.Name = $"{smsModel.Name} ({string.Join(',', storeNames)})";
                        }
                    }

                    //choose phone number to send SMS
                    //currently supported: "my phone" (filled on the configuration page), customer phone, phone of the billing address
                    switch (phoneTypeID)
                    {
                    case 0:
                        smsModel.PhoneType = await _localizationService.GetResourceAsync("Plugins.Misc.Sendinblue.MyPhone");
                        break;

                    case 1:
                        smsModel.PhoneType = await _localizationService.GetResourceAsync("Plugins.Misc.Sendinblue.CustomerPhone");
                        break;

                    case 2:
                        smsModel.PhoneType = await _localizationService.GetResourceAsync("Plugins.Misc.Sendinblue.BillingAddressPhone");
                        break;

                    default:
                        break;
                    }

                    return smsModel;
                }));
            });

            return(Json(model));
        }
コード例 #6
0
 public async Task <SmsSearchModel> GetSmses(SmsSearchModel model)
 {
     return(await _smsApiClient.GetSmses(model));
 }
コード例 #7
0
 public ResponsResult GetSMSList([FromBody] SmsSearchModel model)
 {
     return(_commonService.GetSMSList(model));
 }