Exemplo n.º 1
0
 public FacturaManager()
 {
     crudFactura = new FacturaCrudFactory();
 }
        public async Task Create(Hotel hotel)
        {
            FacturaCrudFactory crudFactura = new FacturaCrudFactory();
            UsuarioManager     mngUsuario  = new UsuarioManager();
            Factura            factura     = new Factura();

            try
            {
                var resFactura = new Factura();
                do
                {
                    var guid        = Guid.NewGuid();
                    var justNumbers = new String(guid.ToString().Where(Char.IsDigit).ToArray());

                    factura.NumFacturacion = int.Parse(justNumbers.Substring(0, 9));
                    resFactura             = crudFactura.Retrieve <Factura>(factura);
                } while (resFactura != null);

                if (hotel.Cadena == null)
                {
                    hotel.Cadena = "";
                }

                hotel.Estado = "Activo";

                hotel.EstadoMembrecia = "Pagada";//Pendiente, Pagada
                hotel.FechaFin        = DateTime.Now;
                hotel.NumFacturacion  = factura.NumFacturacion;

                var c = crudHotel.Retrieve <Hotel>(hotel);

                if (c != null)
                {
                    //El hotel ya fue registrado
                    throw new BussinessException(52);
                }
                else
                {
                    crudHotel.Create(hotel);
                    ParametrizablesHotel param = new ParametrizablesHotel
                    {
                        IdHotel = hotel.CedulaJuridica
                    };
                    mngParametrizablesHotel.Create(param);

                    Usuario usuarioEncontrado = null;

                    var u = new Usuario
                    {
                        Identificacion = hotel.IdGerente
                    };

                    usuarioEncontrado = mngUsuario.RetrieveById(u);

                    var detalleFactura = new LineaDetalleFactura
                    {
                        Nombre   = "Membresía",
                        Precio   = (float)hotel.Membrecia,
                        Cantidad = 1,
                        SubTotal = (float)hotel.Membrecia,
                        Impuesto = 0,
                        Total    = (float)hotel.Membrecia
                    };

                    ArrayList detalle = new ArrayList();
                    detalle.Add(detalleFactura);

                    string numFactura = Convert.ToString(factura.NumFacturacion);

                    await PdfManager.Create(numFactura,
                                            "el pago de una membresía en AdTrip", detalle, hotel,
                                            (Usuario)usuarioEncontrado);
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.GetInstance().Process(ex);
            }
        }
Exemplo n.º 3
0
 public FacturaManagement()
 {
     this.facturaCrudFactory = new FacturaCrudFactory();
 }
Exemplo n.º 4
0
        public async Task Create(Reserva reserva)
        {
            try
            {
                FacturaCrudFactory crudFactura = new FacturaCrudFactory();
                LlaveQRManager     mngLlave    = new LlaveQRManager();
                UsuarioManager     mngUsuario  = new UsuarioManager();
                HotelCrudFactory   crudHotel   = new HotelCrudFactory();


                var     resReserva = crudReserva.Retrieve <Reserva>(reserva);
                Factura factura    = new Factura();


                while (resReserva != null)
                {
                    var guid        = Guid.NewGuid();
                    var justNumbers = new String(guid.ToString().Where(Char.IsDigit).ToArray());
                    reserva.Codigo = int.Parse(justNumbers.Substring(0, 9));
                    resReserva     = crudReserva.Retrieve <Reserva>(reserva);
                }
                ;

                var resFactura = new Factura();
                do
                {
                    var guid        = Guid.NewGuid();
                    var justNumbers = new String(guid.ToString().Where(Char.IsDigit).ToArray());

                    factura.NumFacturacion = int.Parse(justNumbers.Substring(0, 9));
                    resFactura             = crudFactura.Retrieve <Factura>(factura);
                } while (resFactura != null);



                int[] cH   = reserva.CantHabitaciones;
                int   cont = 0;
                var   r    = new Reserva
                {
                    Codigo         = reserva.Codigo,
                    FechaInicio    = reserva.FechaInicio,
                    FechaFin       = reserva.FechaFin,
                    Precio         = reserva.Precio,
                    Promocion      = reserva.Promocion,
                    IdUsuario      = reserva.IdUsuario,
                    IdHotel        = reserva.IdHotel,
                    CantPersonas   = reserva.CantPersonas,
                    NumFacturacion = factura.NumFacturacion
                };


                crudReserva.Create(r);


                cont = 0;

                foreach (string tipoHab in reserva.TipoHabitaciones)
                {
                    var r3 = new Reserva
                    {
                        TipoHab     = tipoHab,
                        CantHab     = cH[cont],
                        Codigo      = reserva.Codigo,
                        IdHotel     = reserva.IdHotel,
                        FechaInicio = reserva.FechaInicio,
                        FechaFin    = reserva.FechaFin
                    };
                    crudReserva.AsignarHabitacionReserva(r3);
                    cont++;
                }


                Usuario usuarioEncontrado = null;

                var u = new Usuario
                {
                    Identificacion = reserva.IdUsuario
                };

                usuarioEncontrado = mngUsuario.RetrieveById(u);


                LlaveQR llave = new LlaveQR();
                llave.EstadoQR  = "1";
                llave.IdReserva = reserva.Codigo;
                llave.IdUsuario = usuarioEncontrado.Correo;

                await mngLlave.CreateYEnviar(llave, usuarioEncontrado);

                var rQR = new LlaveQR
                {
                    IdReserva = reserva.Codigo
                };

                var respuesta = mngLlave.RetrieveAllByReserva(rQR);


                var llaveReserva = new Reserva
                {
                    Codigo  = reserva.Codigo,
                    LlaveQR = respuesta[0].ImagenQR
                };

                crudReserva.AsignarQRReservaReserva(llaveReserva);


                //string numeroFactura, string descripcion, ArrayList detalles, Hotel hotel, Usuario cliente



                var detalleFactura = new LineaDetalleFactura
                {
                    Nombre   = "Reservación",
                    Precio   = (float)reserva.Precio,
                    Cantidad = 1,
                    SubTotal = (float)reserva.Precio,
                    Impuesto = 0,
                    Total    = (float)reserva.Precio
                };

                ArrayList detalle = new ArrayList();
                detalle.Add(detalleFactura);


                var h = new Hotel
                {
                    CedulaJuridica = reserva.IdHotel
                };

                Hotel hotel = crudHotel.Retrieve <Hotel>(h);


                string numFactura = Convert.ToString(factura.NumFacturacion);

                await PdfManager.Create(numFactura,
                                        "el pago de una reservación en AdTrip", detalle, hotel,
                                        (Usuario)usuarioEncontrado);
            }
            catch (Exception ex)
            {
                ExceptionManager.GetInstance().Process(ex);
            }
        }