Пример #1
0
        public static bool PagarWebMethod()
        {
            //Obtener NroPedido seleccionado
            var   Current     = HttpContext.Current;
            Int64 unNroPedido = Int64.Parse(Current.Session["NroPedidoDesdeUltimosPedidos"].ToString());
            //Preparar variables para generar factura
            PedidoCore     unManagerPedido = new PedidoCore();
            PedidoEntidad  unPedidoPagar   = new PedidoEntidad();
            SucursalCore   ManagerSucursal = new SucursalCore();
            UsuarioEntidad logueado        = new UsuarioEntidad();

            logueado = (UsuarioEntidad)Current.Session["Usuario"];

            unPedidoPagar             = unManagerPedido.PedidoSelectByCUIT_NroPedido(unNroPedido);
            unPedidoPagar.misDetalles = unManagerPedido.PedidosDetalleSelect(unPedidoPagar.IdPedido);
            SucursalEntidad unaSucursal = ManagerSucursal.SucursalTraerPorDireccionSucursal(unPedidoPagar.miDireccionEntrega.IdDireccion);

            TarjetaEntidad        unaTarjeta  = new TarjetaEntidad();
            TarjetaCore           coreTarjeta = new TarjetaCore();
            List <TarjetaEntidad> MisTarjetas = coreTarjeta.SelectAllTarjetasByCUIT_NombreUsuario(ConfigSection.Default.Site.Cuit, logueado.NombreUsuario);

            foreach (var t in MisTarjetas)
            {
                if (t.Predeterminada == true)
                {
                    unaTarjeta = t;
                }
            }

            if (unManagerPedido.PagarPedido(unaTarjeta.Numero.ToString(), unaTarjeta.CodSeguridad, (decimal)unPedidoPagar.misDetalles.Select(x => x.Cantidad * x.PrecioUnitario).Sum()))
            {
                unManagerPedido.AvanzarPaso(unPedidoPagar, unaSucursal, logueado, (int)FormaPagoEntidad.Options.ECommerce);
                return(true);
            }
            return(false);

            //LimpiarPedido();
        }
Пример #2
0
        ////Para mantener la sesión activa
        //[WebMethod(EnableSession = true)]
        //public static void MantenerSesion()
        //{

        //}


        protected void Page_Load(object sender, EventArgs e)
        {
            var          Current      = HttpContext.Current;
            SucursalCore coreSucursal = new SucursalCore();

            idioma = new LenguajeEntidad();
            PedidoCore    ManagerPedido   = new PedidoCore();
            PedidoEntidad unPedido        = new PedidoEntidad();
            ProductoCore  ManagerProducto = new ProductoCore();

            NroPedDUltPed = Page.Request.QueryString["NroPedDUltPed"];
            if (!string.IsNullOrEmpty(NroPedDUltPed))
            {
                Current.Session["NroPedidoDesdeUltimosPedidos"] = NroPedDUltPed;
            }
            else
            {
                Response.Redirect("/Areas/Public/Forms/Home.aspx");
            }

            logueado = (UsuarioEntidad)Current.Session["Usuario"];

            if (logueado == null)
            {
                Response.Redirect("/Areas/Public/Forms/Home.aspx");
            }
            if (!IsPostBack)
            {
                idioma = (LenguajeEntidad)Session["Idioma"];

                if (idioma == null)
                {
                    idioma = new LenguajeEntidad();
                    idioma.DescripcionLenguaje = "es";
                    Session["Idioma"]          = idioma;
                }
            }
            else
            {
                idioma.DescripcionLenguaje = Master.obtenerIdiomaCombo();
                Session["Idioma"]          = idioma;
            }
            DropDownList lblIdioma = FindControlFromMaster <DropDownList>("ddlLanguages");

            if (lblIdioma != null)
            {
                lblIdioma.SelectedValue = idioma.DescripcionLenguaje;
            }

            unPedido             = ManagerPedido.PedidoSelectByCUIT_NroPedido(Int64.Parse(NroPedDUltPed));
            unPedido.misDetalles = ManagerPedido.PedidosDetalleSelect(unPedido.IdPedido);
            MonedaEmpresaEntidad cotizacion = (MonedaEmpresaEntidad)Session["Cotizacion"];

            foreach (PedidoDetalleEntidad unDet in unPedido.misDetalles)
            {
                unDet.miProducto = ManagerProducto.Find(unDet.miProducto.IdProducto, cotizacion.IdMoneda);
            }

            FormaEntrega = unPedido.miFormaEntrega.IdFormaEntrega;
            pedido       = unPedido.IdPedido;
            totalizado   = unPedido.misDetalles.Select(x => x.Cantidad * x.miProducto.PrecioUnitario).Sum();
            //TODO: sacarle el precio de envio hardcodeado:
            if (FormaEntrega != null && FormaEntrega == (int)FormaEntregaEntidad.Options.Correo)
            {
                totalizado = totalizado + 100;
            }


            unPedido.misDetalles.ForEach(x => lista.Add(new PedidoLista()
            {
                Cantidad = x.Cantidad,
                Producto = x.miProducto,
                Stock    = true
            }));

            TarjetaCore           coreTarjeta = new TarjetaCore();
            List <TarjetaEntidad> MisTarjetas = coreTarjeta.SelectAllTarjetasByCUIT_NombreUsuario(ConfigSection.Default.Site.Cuit, logueado.NombreUsuario);

            foreach (var t in MisTarjetas)
            {
                if (t.Predeterminada == true)
                {
                    MiTarjeta = t;
                }
            }
        }