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 }); }
public Task <GetSentSmsResponse> Any(GetSentSmsRequest request) { return(this._messagesService.GetPagedSmsListAsync(request)); }