コード例 #1
0
ファイル: SmsService.cs プロジェクト: pantovicmilos/MittoAPI
        public async Task <GetSentSmsResponse> GetPagedSmsListAsync(GetSentSmsRequest dto)
        {
            List <Sms> messages   = new List <Sms>();
            int        totalCount = 0;

            using (var db = _dbFactory.OpenDbConnection())
            {
                SqlExpression <Sms> countQuery = db.From <Sms>()
                                                 .Join <Country>()
                                                 .Where <Sms>(x => x.Created >= dto.DateTimeFrom &&
                                                              x.Created <= dto.DateTimeTo)
                                                 .Select(Sql.Count("*"));

                totalCount = await db.ScalarAsync <int>(countQuery);

                SqlExpression <Sms> pagedQuery = db.From <Sms>()
                                                 .Join <Country>()
                                                 .Where <Sms>(x => x.Created >= dto.DateTimeFrom &&
                                                              x.Created <= dto.DateTimeTo)
                                                 .Skip(dto.Skip)
                                                 .Take(dto.Take);

                messages = await db.LoadSelectAsync <Sms>(pagedQuery);
            }

            return(new GetSentSmsResponse
            {
                Items = messages.ConvertAll(m => m.ToDto()),
                TotalCount = totalCount
            });
        }
コード例 #2
0
 public Task <GetSentSmsResponse> Any(GetSentSmsRequest request)
 {
     return(this._messagesService.GetPagedSmsListAsync(request));
 }