Exemplo n.º 1
0
        public async Task Modificar_Vigencia_Promocion_Success()
        {
            var command = new CreatePromocionCommand
            {
                Bancos                 = new string[] { "Galicia" },
                MediosDePago           = new string[] { "TARJETA_CREDITO" },
                CategoriasProductos    = new string[] { "ElectroCocina" },
                MaximaCantidadDeCuotas = 3,
                FechaInicio            = DateTime.Now.Date.AddDays(-3),
                FechaFin               = DateTime.Now.Date.AddDays(-2)
            };

            CreatePromocionCommandHandler createHandler = new CreatePromocionCommandHandler(_promocionRepositoryAsync, _mapper);
            var promocionCreadaId = await createHandler.Handle(command, default(CancellationToken));

            GetPromocionesVigentesQuery   getPromocionesVigentesQuery   = new GetPromocionesVigentesQuery();
            GetPromocionesVigentesHandler getPromocionesVigentesHandler = new GetPromocionesVigentesHandler(_promocionRepositoryAsync);
            var promocionesVigentes = await getPromocionesVigentesHandler.Handle(getPromocionesVigentesQuery, default(CancellationToken));

            Assert.AreEqual(0, promocionesVigentes.Data.Count());

            UpdateVigenciaPromocionCommand updateVigenciaPromocionCommand = new UpdateVigenciaPromocionCommand
            {
                Id          = promocionCreadaId.Data,
                FechaInicio = command.FechaInicio,
                FechaFin    = DateTime.Now.Date.AddDays(2)
            };
            UpdateVigenciaPromocionCommandHandler updateVigenciaPromocionCommandHandler = new UpdateVigenciaPromocionCommandHandler(_promocionRepositoryAsync);
            await updateVigenciaPromocionCommandHandler.Handle(updateVigenciaPromocionCommand, default(CancellationToken));

            promocionesVigentes = await getPromocionesVigentesHandler.Handle(getPromocionesVigentesQuery, default(CancellationToken));

            Assert.AreEqual(1, promocionesVigentes.Data.Count());
        }
Exemplo n.º 2
0
        public async Task Ver_Promociones_Vigentes_Success()
        {
            var createCommands = new CreatePromocionCommand[]
            {
                new CreatePromocionCommand()
                {
                    Bancos                = new string[] { "Galicia" },
                    MediosDePago          = new string[] { "TARJETA_CREDITO" },
                    CategoriasProductos   = new string[] { "ElectroCocina" },
                    PorcentajeDeDescuento = 30,
                    FechaInicio           = DateTime.Now.Date.AddDays(-1),
                    FechaFin              = DateTime.Now.Date.AddDays(1)
                },
                new CreatePromocionCommand()
                {
                    Bancos                = new string[] { "ICBC" },
                    MediosDePago          = new string[] { "EFECTIVO" },
                    CategoriasProductos   = new string[] { "Colchones" },
                    PorcentajeDeDescuento = 30,
                    FechaInicio           = DateTime.Now.Date.AddDays(-1),
                    FechaFin              = DateTime.Now.Date.AddDays(1)
                },
                new CreatePromocionCommand()
                {
                    Bancos                = new string[] { "ICBC" },
                    MediosDePago          = new string[] { "EFECTIVO" },
                    CategoriasProductos   = new string[] { "Colchones" },
                    PorcentajeDeDescuento = 20,
                    FechaInicio           = DateTime.Now.Date.AddDays(-5),
                    FechaFin              = DateTime.Now.Date.AddDays(-4)
                }
            };

            CreatePromocionCommandHandler createHandler = new CreatePromocionCommandHandler(_promocionRepositoryAsync, _mapper);

            foreach (var cmd in createCommands)
            {
                await createHandler.Handle(cmd, default(CancellationToken));
            }

            GetPromocionesVigentesQuery   getPromocionesVigentesQuery   = new GetPromocionesVigentesQuery();
            GetPromocionesVigentesHandler getPromocionesVigentesHandler = new GetPromocionesVigentesHandler(_promocionRepositoryAsync);

            var promocionesVigentes = await getPromocionesVigentesHandler.Handle(getPromocionesVigentesQuery, default(CancellationToken));

            Assert.AreEqual(2, promocionesVigentes.Data.Count());
        }
Exemplo n.º 3
0
 public async Task <IActionResult> GetVigentes(GetPromocionesVigentesQuery command) =>
 Ok(await Mediator.Send(command));
Exemplo n.º 4
0
        public async Task <Response <IEnumerable <Promocion> > > Handle(GetPromocionesVigentesQuery request, CancellationToken cancellationToken)
        {
            var promociones = await _promocionRepository.GetPromocionesVigentesAsync();

            return(new Response <IEnumerable <Promocion> >(promociones.ToList()));
        }