Exemplo n.º 1
0
        public async Task <PagedResponse <CupResponseModel> > GetCups(GetCupsRequestModel model)
        {
            DateTime?startDate = null;
            DateTime?endDate   = null;

            if (model.Season != null)
            {
                var years = model.Season.Split('-');
                startDate = new DateTime(Convert.ToInt32(years[0]), 11, 1);
                endDate   = new DateTime(Convert.ToInt32(years[1]), 10, 31);
            }

            var(data, count) = await _database.CupsQuery()
                               .GroupBy("c.id HAVING MIN(cd.date) > @StartDate AND MAX(cd.date) < @EndDate",
                                        new { StartDate = startDate, EndDate = endDate?.AddDays(1) }, onlyIf: startDate.HasValue)
                               .OrderBy("end_date DESC, c.name DESC")
                               .PageAndCountAsync(model.Page, model.PageSize);

            return(new PagedResponse <CupResponseModel>(data, model.Page, model.PageSize, count));
        }
Exemplo n.º 2
0
 public Task <Responses.PagedResponse <CupResponseModel> > GetCups(GetCupsRequestModel model)
 {
     return(_cupService.GetCups(model));
 }