public void CargarCupones() { if (TarjetaSeleccionada > -1) { var cupones = chkTodosLosCupones.CheckState == CheckState.Checked ? SySTarjetasService.TraerCuponesPorTarjeta(TarjetaSeleccionada) : SySTarjetasService.TraerCuponesPorTarjetaAnioYMes(TarjetaSeleccionada, AñoSeleccionado, MesSeleccionado); var listadoCupones = cupones.Select( x => new { Id = x.Id, RazonSocial = x.Comercio != null ? x.Comercio.RazonSocial : "[[DESCONOCIDO]]", FechaCompra = x.FechaCompra.ToShortDateString(), FechaCompraParaOrdenar = x.FechaCompra, NumeroCupon = x.NumeroCupon, Importe = x.Importe, ImporteFormateado = x.Importe.ToString("N"), Cuotas = x.CantidadCuotas }).ToList(); gridCupones.DataSource = listadoCupones.OrderBy(x => x.FechaCompraParaOrdenar); gridCupones.Refresh(); lblTotal.Text = listadoCupones.Sum(x => x.Importe).ToString("N"); } }
public PagedResponse <CuponViewModel> List(int tarjetaId, int anio, int mes, bool listarTodos, int pageSize, int pageNumber) { var listadoCupones = new List <CuponViewModel>(); var totalCount = 0; if (tarjetaId > -1) { var cupones = listarTodos ? SySTarjetasService.TraerCuponesPorTarjeta(tarjetaId) : SySTarjetasService.TraerCuponesPorTarjetaAnioYMes(tarjetaId, anio, mes); totalCount = cupones.Count; listadoCupones = cupones.OrderBy(x => x.FechaCompra).Skip((pageNumber - 1) * pageSize).Take(pageSize).Select( x => Mapper.Map <CuponViewModel>(x)).ToList(); } return(new PagedResponse <CuponViewModel>(listadoCupones.OrderBy(x => x.FechaCompraParaOrdenar).ToList(), pageNumber, pageSize, totalCount)); }