public async Task <Unit> Handle(CancelSaleCommand request, CancellationToken cancellationToken) { var context = contextService.GetContextVoucher(request.NrVoucher); string proposta = request.NrVoucher.Substring(0, request.NrVoucher.Length - 2); string passageiro = request.NrVoucher.Substring(request.NrVoucher.Length - 2); PoPolizas poliza = await context.PoPolizas.Where(x => x.NumeroPoliza == proposta).FirstOrDefaultAsync(cancellationToken); var bilhetes = context.PoBeneficiariosPoliza.Where(x => x.IdPoliza == poliza.IdPoliza); foreach (var bilhete in bilhetes) { bilhete.FechaAnulacion = poliza.FechaDesde; context.PoBeneficiariosPoliza.Update(bilhete); } poliza.FechaAnulacion = poliza.FechaDesde; await context.SaveChangesAsync(cancellationToken); return(Unit.Value); }
public async Task <Unit> Handle(CancelVoucherCommand request, CancellationToken cancellationToken) { var context = contextService.GetContextVoucher(request.NrBilhete); string proposta = request.NrBilhete.Substring(0, request.NrBilhete.Length - 2); string passageiro = request.NrBilhete.Substring(request.NrBilhete.Length - 2); PoPolizas poliza = context.PoPolizas.Where(x => x.NumeroPoliza == proposta).FirstOrDefault(); var bilhete = context.PoBeneficiariosPoliza.Where(x => x.IdPoliza == poliza.IdPoliza && x.Secuencia == int.Parse(passageiro)).FirstOrDefault(); bilhete.FechaAnulacion = poliza.FechaDesde; poliza.FechaAnulacion = poliza.FechaDesde; await context.SaveChangesAsync(cancellationToken); return(Unit.Value); }
public async Task <Unit> Handle(CancelVoucherRetroactCommand request, CancellationToken cancellationToken) { var context = contextService.GetContextVoucher(request.NrVoucher); var dataCancelamento = DateTime.ParseExact(request.Data, "d-M-yyyy", CultureInfo.InvariantCulture); string proposta = request.NrVoucher.Substring(0, request.NrVoucher.Length - 2); string passageiro = request.NrVoucher.Substring(request.NrVoucher.Length - 2); PoPolizas poliza = await context.PoPolizas.Where(x => x.NumeroPoliza == proposta).FirstOrDefaultAsync(cancellationToken); var bilhete = context.PoBeneficiariosPoliza.Where(x => x.IdPoliza == poliza.IdPoliza && x.Secuencia == int.Parse(passageiro)).FirstOrDefault(); poliza.FechaAnulacion = dataCancelamento; bilhete.FechaAnulacion = poliza.FechaDesde; await context.SaveChangesAsync(cancellationToken); return(Unit.Value); }