//Metodo CRUD DELETE
        public bool Eliminar(ServicioBLL servicioBL)
        {
            SqlCommand sqlCommand = new SqlCommand("DELETE FROM Servicio WHERE id = @ID"); //Creamos el comando

            sqlCommand.Parameters.Add("@ID", SqlDbType.Int).Value = servicioBL.ID;         //Agregamos los parametros
            return(conexion.EjecutarComandoSinRetornoDatos(sqlCommand));                   //Ejecutamos el comando
        }
Exemple #2
0
 public ActionResult Edit([Bind(Include = "idservicio,nombre,costo,descripcion,idempresa")] Servicio servicio)
 {
     if (ModelState.IsValid)
     {
         ServicioBLL.Update(servicio);
         return(RedirectToAction("Index"));
     }
     ViewBag.idempresa = new SelectList(EmpresaBLL.List(), "idempresa", "nombre", servicio.idempresa);
     return(View(servicio));
 }
        private ServicioBLL RecuperarInformacion()
        {
            ServicioBLL servicioBLL = new ServicioBLL();

            servicioBLL.IDCliente = int.Parse(cbxCliente.SelectedValue.ToString());
            servicioBLL.IDUnidad  = int.Parse(cbxUnidad.SelectedValue.ToString());
            servicioBLL.Origen    = txtOrigen.Text;
            servicioBLL.CV        = txtCV.Text;
            servicioBLL.ID        = IDAux;
            return(servicioBLL);
        }
Exemple #4
0
 public ActionResult Edit([Bind(Include = "idpedido,fechaPeticion,fechaEjecucion,idservicio,idcliente")] Pedido pedido)
 {
     if (ModelState.IsValid)
     {
         PedidoBLL.Update(pedido);
         return(RedirectToAction("Index"));
     }
     ViewBag.idcliente  = new SelectList(ClienteBLL.ListToNames(), "idcliente", "nombre", pedido.idcliente);
     ViewBag.idservicio = new SelectList(ServicioBLL.ListToNames(), "idservicio", "nombre", pedido.idservicio);
     return(View(pedido));
 }
Exemple #5
0
        public FormServicios()
        {
            servicioBLL = new ServicioBLL();
            servicioDAL = new ServicioDAL();

            InitializeComponent();
            btnEditar.Visible = false;
            button2.Visible   = false;//es el boton de eliminar
            LlenarGrid();
            //dataGridView1.Rows.Insert(0,"1", "2013081242", "AEC-234-23", "México", "Veracruz", "Pancho", "5574419398");
        }
Exemple #6
0
 public IHttpActionResult Delete(int id)
 {
     try
     {
         ServicioBLL.Delete(id);
         return(Ok("Servicio eliminado correctamente"));
     }
     catch (Exception ex)
     {
         return(Content(HttpStatusCode.BadRequest, ex));
     }
 }
Exemple #7
0
 public IHttpActionResult Get()
 {
     try
     {
         List <Servicio> todos = ServicioBLL.List();
         return(Content(HttpStatusCode.OK, todos));
     }
     catch (Exception ex)
     {
         return(Content(HttpStatusCode.BadRequest, ex));
     }
 }
Exemple #8
0
 public IHttpActionResult Put(Servicio servicio)
 {
     try
     {
         ServicioBLL.Update(servicio);
         return(Content(HttpStatusCode.OK, "Servicio actualizado correctamente"));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Exemple #9
0
 public IHttpActionResult Post(Servicio servicio)
 {
     try
     {
         ServicioBLL.Create(servicio);
         return(Content(HttpStatusCode.Created, "Servicio creado correctamente"));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
        public ActionResult AddServicio(Servicio s)
        {
            var pv       = Session["PedidoView"] as PedidoView;
            var id       = int.Parse(Request["idservicio"]);
            var costo    = Convert.ToDecimal(pv.Costo);
            var servicio = ServicioBLL.Get(id);

            pv.Servicios.Add(servicio);
            costo             += Convert.ToDecimal(servicio.costo) / 100;
            pv.Costo           = Convert.ToString(costo);
            ViewBag.idcliente  = new SelectList(ClienteBLL.ListToNames(), "idcliente", "nombre");
            ViewBag.idservicio = new SelectList(ServicioBLL.ListToNames(), "idservicio", "nombre");
            return(View("NuevoPedido", pv));
        }
Exemple #11
0
        // GET: Servicios/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Servicio servicio = ServicioBLL.Get(id);

            if (servicio == null)
            {
                return(HttpNotFound());
            }
            return(View(servicio));
        }
Exemple #12
0
        //Metodo CRUD UPDATE
        public bool Modificar(ServicioBLL servicioBLL)
        {
            SqlCommand sqlCommand = new SqlCommand("UPDATE Servicio SET id_Cliente=@id_Cliente, id_Unidad=@id_Unidad, origen=@origen, cv=@cv WHERE id=@ID"); //Creamos el comando

            sqlCommand.Parameters.Add("@ID", SqlDbType.Int).Value         = servicioBLL.ID;                                                                  //Agregamos los parametros
            sqlCommand.Parameters.Add("@id_Unidad", SqlDbType.Int).Value  = servicioBLL.IDUnidad;
            sqlCommand.Parameters.Add("@id_Cliente", SqlDbType.Int).Value = servicioBLL.IDCliente;
            sqlCommand.Parameters.Add("@origen", SqlDbType.VarChar).Value = servicioBLL.Origen;
            sqlCommand.Parameters.Add("@cv", SqlDbType.VarChar).Value     = servicioBLL.CV;


            //MessageBox.Show(" "+clienteBLL.ID +clienteBLL.Empresa+clienteBLL.Direccion);

            return(conexion.EjecutarComandoSinRetornoDatos(sqlCommand));//Ejecutamos el comando
        }
Exemple #13
0
        // GET: Servicios/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Servicio servicio = ServicioBLL.Get(id);

            if (servicio == null)
            {
                return(HttpNotFound());
            }
            ViewBag.idempresa = new SelectList(EmpresaBLL.List(), "idempresa", "nombre", servicio.idempresa);
            return(View(servicio));
        }
Exemple #14
0
 public IHttpActionResult GetOne(int id)
 {
     try
     {
         Servicio result = ServicioBLL.Get(id);
         if (result == null)
         {
             return(NotFound());
         }
         return(Content(HttpStatusCode.OK, result));
     }
     catch (Exception ex)
     {
         return(Content(HttpStatusCode.BadRequest, ex));
     }
 }
Exemple #15
0
 public IHttpActionResult GetByBussiness(int id)
 {
     try
     {
         List <Servicio> result = ServicioBLL.List(id);
         if (result == null)
         {
             return(NotFound());
         }
         return(Content(HttpStatusCode.OK, result));
     }
     catch (Exception ex)
     {
         return(Content(HttpStatusCode.BadRequest, ex));
     }
 }
Exemple #16
0
        // GET: Pedidos/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Pedido pedido = PedidoBLL.Get(id);

            if (pedido == null)
            {
                return(HttpNotFound());
            }
            ViewBag.idcliente  = new SelectList(ClienteBLL.ListToNames(), "idcliente", "nombre", pedido.idcliente);
            ViewBag.idservicio = new SelectList(ServicioBLL.ListToNames(), "idservicio", "nombre", pedido.idservicio);
            return(View(pedido));
        }
Exemple #17
0
        //Metodo CRUD CREATE
        public bool Agregar(ServicioBLL servicioBLL)
        {
            //MessageBox.Show("AQUIIIIII" + servicioBLL.IDCliente + servicioBLL.IDUnidad + servicioBLL.Origen + servicioBLL.CV);


            SqlCommand sqlCommand = new SqlCommand("INSERT INTO Servicio(id_Cliente, id_Unidad, origen, cv) VALUES(@id_Cliente,@id_Unidad,@origen,@cv)");//Creamos el comando

            //sqlCommand.Parameters.Add("@id", SqlDbType.Int).Value = servicioBLL.ID;//Agregamos los parametros
            sqlCommand.Parameters.Add("@id_Cliente", SqlDbType.Int).Value = servicioBLL.IDCliente;
            sqlCommand.Parameters.Add("@id_Unidad", SqlDbType.Int).Value  = servicioBLL.IDUnidad;
            sqlCommand.Parameters.Add("@origen", SqlDbType.VarChar).Value = servicioBLL.Origen;
            sqlCommand.Parameters.Add("@cv", SqlDbType.VarChar).Value     = servicioBLL.CV;

            return(conexion.EjecutarComandoSinRetornoDatos(sqlCommand));//Ejecutamos el comando

            //return conexion.EjecutarComandoSinRetornoDatos("INSERT INTO Cliente(Empresa, Direccion, RFC, Contacto, Giro) VALUES('"+clienteBLL.Empresa+ "', '" + clienteBLL.Direccion + "', '" + clienteBLL.RFC + "', '" + clienteBLL.Contacto + "', '" + clienteBLL.Giro + "')");
        }
Exemple #18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ServicioBLL unServicioBLL = new ServicioBLL();

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

            string nombre = Session["NomUsuario"].ToString();

            IdiomaSeleccionado = (IdiomaEntidad)Current.Session["Idioma"];
            if (usuarioentidad == null)
            {
                Response.Redirect("Default.aspx");
            }


            // Cargo el repeater con los servicios en venta
            unServicios             = (List <ServicioEntidad>)unServicioBLL.SelectALLServicios();
            InfoServicio.DataSource = unServicios;
            InfoServicio.DataBind();

            Traducciones = new List <MultiIdiomaEntidad>();

            Traducciones = IdiomaBLL.GetBLLServicioIdiomaUnico().TraduccionesSgl;
        }
        public static BaseResponse ProcessBill(ref BillEntity pBill, CreditOrDebitNoteEntity pDocumentReference)
        {
            BaseResponse vResponse = new BaseResponse {
                IsSuccessful = false
            };

            pBill.Status = BillStatus.Error.ToString();
            try
            {
                var vServicioBLL         = new ServicioBLL();
                var vDocumentoEncabezado = new DocumentoEncabezado();
                var vUsuarioHacienda     = new UsuarioHacienda();
                var vListaMedioPago      = new List <DocumentoMedioPago>();
                var vDetalleDocumento    = new List <DocumentoDetalle>();

                //Encabezado
                vDocumentoEncabezado.Clave                     = pBill.DocumentKey;
                vDocumentoEncabezado.TipoCambio                = 1.00;
                vDocumentoEncabezado.Fecha                     = DateTime.Now;
                vDocumentoEncabezado.Moneda                    = "CRC";
                vDocumentoEncabezado.CondicionVenta            = pBill.SellCondition;
                vDocumentoEncabezado.PlazoCredito              = string.IsNullOrEmpty(pBill.CreditTerm)?"0": pBill.CreditTerm;
                vDocumentoEncabezado.NormativaFechaResolucion  = "20-02-2017 13:22:22";
                vDocumentoEncabezado.NormativaNumeroResolucion = "DGT-R-48-2016";
                vDocumentoEncabezado.Observacion               = string.IsNullOrEmpty(pBill.Observation) ? string.Empty: pBill.Observation;
                vDocumentoEncabezado.SubTotal                  = Convert.ToDouble(pBill.SubTotalProducts);
                vDocumentoEncabezado.Descuento                 = Convert.ToDouble(pBill.DiscountAmount);
                vDocumentoEncabezado.Impuesto                  = Convert.ToDouble(pBill.TaxesToPay);
                vDocumentoEncabezado.DocumentoConsecutivo      = pBill.ConsecutiveNumber + "";

                //Emisor
                vDocumentoEncabezado.Emisor.Identificacion     = pBill.User.UserLegalNumber;
                vDocumentoEncabezado.Emisor.IdentificacionTipo = pBill.User.IdentificationType;
                vDocumentoEncabezado.Emisor.Direccion          = pBill.User.LocationDescription;
                vDocumentoEncabezado.Emisor.CodigoPais         = "506";
                vDocumentoEncabezado.Emisor.Provincia          = pBill.User.ProvinciaCode;
                vDocumentoEncabezado.Emisor.Canton             = pBill.User.CantonCode;
                vDocumentoEncabezado.Emisor.Distrito           = pBill.User.DistritoCode;
                vDocumentoEncabezado.Emisor.Barrio             = pBill.User.BarrioCode;
                vDocumentoEncabezado.Emisor.Nombre             = pBill.User.Name;
                vDocumentoEncabezado.Emisor.NombreComercial    = string.IsNullOrEmpty(pBill.User.ComercialName)? string.Empty: pBill.User.ComercialName;
                vDocumentoEncabezado.Emisor.Telefono           = pBill.User.PhoneNumber;
                vDocumentoEncabezado.Emisor.Fax   = "00000000";
                vDocumentoEncabezado.Emisor.Email = pBill.User.Email;

                //Receptor
                vDocumentoEncabezado.Receptor.IdentificacionExtranjero = pBill.Client.ForeignIdentification;
                vDocumentoEncabezado.Receptor.Identificacion           = pBill.Client.ClientLegalNumber;
                vDocumentoEncabezado.Receptor.IdentificacionTipo       = pBill.Client.IdentificationType;
                vDocumentoEncabezado.Receptor.Direccion       = pBill.Client.LocationDescription;
                vDocumentoEncabezado.Receptor.CodigoPais      = "506";
                vDocumentoEncabezado.Receptor.Provincia       = pBill.Client.ProvinciaCode;
                vDocumentoEncabezado.Receptor.Canton          = pBill.Client.CantonCode;
                vDocumentoEncabezado.Receptor.Distrito        = pBill.Client.DistritoCode;
                vDocumentoEncabezado.Receptor.Barrio          = pBill.Client.BarrioCode;
                vDocumentoEncabezado.Receptor.Nombre          = pBill.Client.Name;
                vDocumentoEncabezado.Receptor.NombreComercial = pBill.Client.ComercialName;
                vDocumentoEncabezado.Receptor.Telefono        = pBill.Client.PhoneNumber;
                vDocumentoEncabezado.Receptor.Fax             = "00000000";
                vDocumentoEncabezado.Receptor.Email           = pBill.Client.Email;

                //Medio de Pago
                var vMedioDePago = new DocumentoMedioPago();
                vMedioDePago.Codigo = pBill.PaymentMethod;
                vListaMedioPago.Add(vMedioDePago);
                vDocumentoEncabezado.MedioPago = vListaMedioPago;

                var vListaProductos = JsonConvert.DeserializeObject <Client>(pBill.SoldProductsJSON);
                foreach (var vProducto in vListaProductos.ClientProducts)
                {
                    if (vProducto.ProductQuantity > 0)
                    {
                        //Detalle del Producto
                        decimal vProductTotal = vProducto.Price * vProducto.ProductQuantity;
                        var     vLinea        = new DocumentoDetalle();
                        vLinea.Cantidad              = vProducto.ProductQuantity;
                        vLinea.Nombre                = vProducto.Name;
                        vLinea.Descripcion           = vProducto.Description;
                        vLinea.Codigo                = vProducto.ProductCode;
                        vLinea.Tipo                  = vProducto.ProductType;
                        vLinea.Unidad                = vProducto.MeasurementUnit;
                        vLinea.UnidadMedidaComercial = string.IsNullOrEmpty(vProducto.MeasurementUnitType)?string.Empty: vProducto.MeasurementUnitType;
                        vLinea.EsProducto            = true;
                        vLinea.Precio                = Convert.ToDouble(vProducto.Price);
                        vLinea.Descuento             = Convert.ToDouble((vProductTotal / 100) * pBill.Client.DefaultDiscountPercentage);
                        vLinea.DescuentoDescripcion  = string.IsNullOrEmpty(pBill.DiscountNature) ? string.Empty : pBill.DiscountNature;
                        if (pBill.Client.DefaultTaxesPercentage > 0)
                        {
                            // Impuestos
                            var vLineaListaImpuesto = new List <DocumentoDetalleImpuesto>();
                            var vLineaImpuesto      = new DocumentoDetalleImpuesto();
                            vLineaImpuesto.Tipo   = pBill.TaxCode;
                            vLineaImpuesto.Tarifa = Convert.ToDouble(pBill.Client.DefaultTaxesPercentage);
                            vLineaImpuesto.Monto  =
                                Convert.ToDouble(((vProductTotal - Convert.ToDecimal(vLinea.Descuento)) / 100) * pBill.Client.DefaultTaxesPercentage);
                            vLineaListaImpuesto.Add(vLineaImpuesto);
                            // Se agrega el impuesto a Lista
                            vLinea.DocumentoDetalleImpuesto = vLineaListaImpuesto;
                        }

                        // Se agrega el Producto completo a todos los demas
                        vDetalleDocumento.Add(vLinea);
                    }
                    else
                    {
                        // El producto no tiene ninguna cantidad a facturar
                    }
                }

                //Se agrega referencia si es que existe
                if (pDocumentReference != null)
                {
                    var vReferenceList = new List <DocumentoReferencia>();
                    var vReferenceDoc  = new DocumentoReferencia();

                    vReferenceDoc.Codigo       = pDocumentReference.ReferenceCode;
                    vReferenceDoc.FechaEmision = pDocumentReference.EmissionDate;
                    vReferenceDoc.Numero       = pDocumentReference.DocuementKey;
                    vReferenceDoc.Razon        = pDocumentReference.ReasonDescription;
                    vReferenceDoc.TipoDoc      = HaciendaTransactionType.Factura_Electronica;

                    vReferenceList.Add(vReferenceDoc);
                    vDocumentoEncabezado.Referencia = vReferenceList;
                }

                // Se agrega el Segmento de todos los productos
                vDocumentoEncabezado.DocumentoDetalle = vDetalleDocumento;

                // Datos de Hacienda
                vUsuarioHacienda.username                     = pBill.Client.User.HaciendaUsername;
                vUsuarioHacienda.password                     = pBill.Client.User.HaciendaPassword;
                vUsuarioHacienda.Pin                          = pBill.Client.User.HaciendaCryptographicPIN;
                vUsuarioHacienda.Certificado                  = pBill.Client.User.HaciendaCryptographicFile;
                vUsuarioHacienda.modalidadProduccion          = false;
                vUsuarioHacienda.urlhaciendaAuthApiDesarrollo = UrlhaciendaAuthApiDesarrollo;
                vUsuarioHacienda.urlhaciendaAuthApiProduccion = UrlhaciendaAuthApiProduccion;
                vUsuarioHacienda.urlhaciendaApiDesarrollo     = UrlhaciendaApiDesarrollo;
                vUsuarioHacienda.urlhaciendaApiProduccion     = UrlhaciendaApiProduccion;

                var vReply = vServicioBLL.fGenerarDocumento(vDocumentoEncabezado, vUsuarioHacienda, MaxRetryCount);
                if (vReply != null)
                {
                    // try to save the Sended XML always
                    if (!string.IsNullOrEmpty(vReply.xmlDocumento))
                    {
                        pBill.XMLSendedToHacienda = vReply.xmlDocumento;
                    }

                    if (!string.IsNullOrEmpty(vReply.xmlRespuesta))
                    {
                        Regex  vRegex = new Regex("<DetalleMensaje>(.+)</DetalleMensaje>");
                        string msgWithoutChangeLines = Regex.Replace(vReply.xmlRespuesta, "\r\n?|\n", "");
                        var    vMatch = vRegex.Match(msgWithoutChangeLines);
                        if (vMatch.Success)
                        {
                            pBill.SystemMesagges = vReply.estado + "-" + vReply.msg + vMatch.Value;
                        }
                        else
                        {
                            pBill.SystemMesagges = vReply.estado + "-" + vReply.msg;
                        }
                    }
                    else
                    {
                        pBill.SystemMesagges = vReply.estado + "-" + vReply.msg +
                                               string.Format("| REASON GET: {0} | REASON POST: {1}", vReply.reasonPhraseGETHacienda, vReply.reasonPhrasePOSTHacienda);
                    }


                    if (vReply.ok)
                    {
                        if (!string.IsNullOrEmpty(vReply.xmlRespuesta))
                        {
                            pBill.XMLReceivedFromHacienda = vReply.xmlRespuesta;
                        }
                        switch (vReply.estado)
                        {
                        case BillStatusHacienda.Aceptada:
                            pBill.Status           = BillStatus.Done.ToString();
                            vResponse.IsSuccessful = true;
                            break;

                        case BillStatusHacienda.Rechazada:
                            pBill.Status           = BillStatus.Rejected.ToString();
                            vResponse.IsSuccessful = false;
                            break;

                        case BillStatusHacienda.Procesando:
                            pBill.Status           = BillStatus.Processing.ToString();
                            vResponse.IsSuccessful = false;
                            break;

                        default:
                            pBill.Status           = BillStatus.Error.ToString();
                            vResponse.IsSuccessful = false;
                            break;
                        }

                        if (string.IsNullOrEmpty(pBill.SystemMesagges))
                        {
                            pBill.SystemMesagges = pBill.Status + vReply.msg;
                        }
                        vResponse.UserMessage = pBill.SystemMesagges;
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(pBill.Status))
                        {
                            pBill.Status = BillStatus.Error.ToString();
                        }
                        if (string.IsNullOrEmpty(pBill.SystemMesagges))
                        {
                            pBill.SystemMesagges = "Error." + "La respuesta no fue positiva:" + vReply.msg;
                        }


                        if (string.IsNullOrEmpty(vReply.statusCodePOSTHacienda) || !vReply.statusCodePOSTHacienda.Equals(AcceptedHTTPCode))
                        {
                            if (!string.IsNullOrEmpty(vReply.msg) && vReply.msg.Contains("ya fue recibido anteriormente"))
                            {
                                pBill.Status = BillStatus.Processing.ToString();
                            }
                            else
                            {
                                pBill.Status = BillStatus.Error.ToString();
                            }
                        }
                        else
                        {
                            pBill.Status = BillStatus.Processing.ToString();
                        }
                        pBill.ReasonPhraseGETHacienda  = vReply.reasonPhraseGETHacienda;
                        pBill.ReasonPhrasePOSTHacienda = vReply.reasonPhrasePOSTHacienda;

                        pBill.StatusCodeGETHacienda  = vReply.statusCodeGETHacienda;
                        pBill.StatusCodePOSTHacienda = vReply.statusCodePOSTHacienda;

                        vResponse.IsSuccessful = false;
                        vResponse.UserMessage  = pBill.SystemMesagges;
                    }
                }
                else
                {
                    pBill.SystemMesagges  = "No se recibio respuesta de hacienda";
                    vResponse.UserMessage = "Error." + "No se recibio respuesta de hacienda";
                    pBill.Status          = BillStatus.Error.ToString();
                }

                pBill.HaciendaFailCounter++;
            }
            catch (Exception ex)
            {
                vResponse.UserMessage      = ex.Message;
                vResponse.TechnicalMessage = ex.ToString();
                vResponse.IsSuccessful     = false;
            }

            return(vResponse);
        }
 public ActionResult AddServicio()
 {
     ViewBag.idservicio = new SelectList(ServicioBLL.ListToNames(), "idservicio", "nombre");
     return(View());
 }
        public static BaseResponse TryToRefreshBillStatus(ref BillEntity pBill)
        {
            BaseResponse vResponse = new BaseResponse {
                IsSuccessful = false
            };

            try
            {
                var vServicioBLL     = new ServicioBLL();
                var vTributacionBLL  = new TributacionBLL();
                var vUsuarioHacienda = new UsuarioHacienda();

                // Datos de Hacienda
                vUsuarioHacienda.username                     = pBill.Client.User.HaciendaUsername;
                vUsuarioHacienda.password                     = pBill.Client.User.HaciendaPassword;
                vUsuarioHacienda.Pin                          = pBill.Client.User.HaciendaCryptographicPIN;
                vUsuarioHacienda.Certificado                  = pBill.Client.User.HaciendaCryptographicFile;
                vUsuarioHacienda.modalidadProduccion          = false;
                vUsuarioHacienda.urlhaciendaAuthApiDesarrollo = UrlhaciendaAuthApiDesarrollo;
                vUsuarioHacienda.urlhaciendaAuthApiProduccion = UrlhaciendaAuthApiProduccion;
                vUsuarioHacienda.urlhaciendaApiDesarrollo     = UrlhaciendaApiDesarrollo;
                vUsuarioHacienda.urlhaciendaApiProduccion     = UrlhaciendaApiProduccion;


                var vReplyValidaCertificado = vServicioBLL.fValidarCertificado(vUsuarioHacienda);
                if (vReplyValidaCertificado.ok)
                {
                    var vReplyGeneraToken = vTributacionBLL.fGeneraToken(vUsuarioHacienda);
                    if (vReplyGeneraToken.ok && vReplyGeneraToken.contingencia == false)
                    {
                        Boolean vValidAnswer = false;
                        for (int vCounter = 0; vCounter < MaxRetryCount && !vValidAnswer; vCounter++)
                        {
                            var vReplyObtieneRespuesta = vTributacionBLL.fObtenerDocumento(vUsuarioHacienda, pBill.DocumentKey, vReplyGeneraToken.token);

                            pBill.ReasonPhraseGETHacienda = vReplyObtieneRespuesta.reasonPhraseGETHacienda;
                            pBill.StatusCodeGETHacienda   = vReplyObtieneRespuesta.statusCodeGETHacienda;

                            if (vReplyObtieneRespuesta.ok)
                            {
                                pBill.XMLReceivedFromHacienda = vReplyObtieneRespuesta.xmlRespuesta;

                                switch (vReplyObtieneRespuesta.msg)
                                {
                                case "ACEPTADO":

                                    pBill.SystemMesagges   = "Documento: " + pBill.DocumentKey + " | POST Hacienda: True |  GET Hacienda: True | Descripción: ACEPTADO";
                                    vResponse.UserMessage  = pBill.SystemMesagges;
                                    pBill.Status           = BillStatus.Done.ToString();
                                    vResponse.IsSuccessful = true;
                                    vValidAnswer           = true;
                                    break;

                                case "RECHAZADO":
                                    pBill.SystemMesagges   = "Documento: " + pBill.DocumentKey + " | POST Hacienda: True |  GET Hacienda: True | Descripción: RECHAZADO";
                                    vResponse.UserMessage  = pBill.SystemMesagges;
                                    pBill.Status           = BillStatus.Rejected.ToString();
                                    vResponse.IsSuccessful = false;
                                    vValidAnswer           = true;
                                    break;


                                case "PROCESANDO":

                                    pBill.SystemMesagges = "Documento: " + pBill.DocumentKey + " | POST Hacienda: True |  GET Hacienda: True | Descripción: PROCESANDO";
                                    pBill.Status         = BillStatus.Processing.ToString();
                                    break;


                                default:

                                    pBill.SystemMesagges = "Documento: " + pBill.DocumentKey + " | POST Hacienda: True |  GET Hacienda: True | Descripción: ERROR HACIENDA. CONTACTE A SOPORTE HACIENDA";
                                    pBill.Status         = BillStatus.Error.ToString();
                                    break;
                                }
                            }
                            else
                            {
                                pBill.SystemMesagges = "Documento: " + pBill.DocumentKey + " | POST Hacienda: True | GET Hacienda: True | Descripción: " + vReplyObtieneRespuesta.msg;
                                pBill.Status         = BillStatus.Error.ToString();
                            }
                            pBill.SystemMesagges = vReplyObtieneRespuesta.estado + "-" + pBill.SystemMesagges + string.Format("| REASON GET: {0} | REASON POST: {1}", pBill.ReasonPhraseGETHacienda, pBill.ReasonPhrasePOSTHacienda);
                        }
                    }
                    else
                    {
                        vResponse.UserMessage      = vReplyGeneraToken.msg;
                        vResponse.TechnicalMessage = vReplyGeneraToken.msg;
                    }
                }
                else
                {
                    vResponse.UserMessage      = vReplyValidaCertificado.msg;
                    vResponse.TechnicalMessage = vReplyValidaCertificado.msg;
                }
            }
            catch (Exception vEx)
            {
                vResponse.UserMessage      = vEx.Message;
                vResponse.TechnicalMessage = vEx.ToString();
                vResponse.IsSuccessful     = false;
            }
            return(vResponse);
        }
Exemple #22
0
 // GET: Pedidos/Create
 public ActionResult Create()
 {
     ViewBag.idcliente  = new SelectList(ClienteBLL.ListToNames(), "idcliente", "nombre");
     ViewBag.idservicio = new SelectList(ServicioBLL.ListToNames(), "idservicio", "nombre");
     return(View());
 }
Exemple #23
0
 // GET: Servicios
 public ActionResult Index()
 {
     return(View(ServicioBLL.List()));
 }
Exemple #24
0
 public ActionResult DeleteConfirmed(int id)
 {
     ServicioBLL.Delete(id);
     return(RedirectToAction("Index"));
 }
Exemple #25
0
        public BaseResponse ValidateUserCredentials(DataContracts.MobileModel.User pNewUser, bool pIsProduction = false)
        {
            var vResponse = new BaseResponse();

            vResponse.IsSuccessful = false;

            // Validacion de Credenciales
            var   vServicioBLL       = new ServicioBLL();
            Reply vTokenReplyMessage = new Reply();
            var   vUsuarioHacienda   = new UsuarioHacienda();

            vUsuarioHacienda.modalidadProduccion          = pIsProduction;
            vUsuarioHacienda.urlhaciendaAuthApiDesarrollo = BillingConstants.UrlhaciendaAuthApiDesarrollo;
            vUsuarioHacienda.urlhaciendaAuthApiProduccion = BillingConstants.UrlhaciendaAuthApiProduccion;
            vUsuarioHacienda.username = pNewUser.HaciendaUsername;
            vUsuarioHacienda.password = pNewUser.HaciendaPassword;

            vTokenReplyMessage = vServicioBLL.fGenerarToken(vUsuarioHacienda);
            if (vTokenReplyMessage != null && vTokenReplyMessage.ok &&
                vTokenReplyMessage.token != null && !string.IsNullOrEmpty(vTokenReplyMessage.token.access_token))
            {
                vTokenReplyMessage           = new Reply();
                vUsuarioHacienda.Certificado = Convert.FromBase64String(pNewUser.HaciendaCryptographicFile);
                vUsuarioHacienda.Pin         = Convert.ToString(pNewUser.HaciendaCryptographicPIN);

                vTokenReplyMessage = vServicioBLL.fValidarCertificado(vUsuarioHacienda);

                if (vTokenReplyMessage != null && vTokenReplyMessage.ok)
                {
                    vResponse.UserMessage  = "Usuario Validado con éxito";
                    vResponse.IsSuccessful = true;
                }
                else
                {
                    vResponse.UserMessage  = vTokenReplyMessage?.msg;
                    vResponse.IsSuccessful = false;
                }

                /*
                 * Dim vUsuarioHacienda As New UsuarioHacienda()
                 * Dim vReply As New Reply
                 *
                 * ' Asigna datos
                 * vUsuarioHacienda.Certificado = IO.File.ReadAllBytes(txtCertificado.Text)
                 * vUsuarioHacienda.Pin = txtCertificadoPIN.Text
                 *
                 * ' Valida PIN y Certificado
                 * vReply = vServicioBLL.fValidarCertificado(vUsuarioHacienda)
                 */
            }
            else
            {
                vResponse.UserMessage  = vTokenReplyMessage?.msg;
                vResponse.IsSuccessful = false;
            }

            /*
             * Dim vUsuarioHacienda As New UsuarioHacienda()
             *
             * ' Asigna datos
             * vUsuarioHacienda.modalidadProduccion = False
             * vUsuarioHacienda.urlhaciendaAuthApiDesarrollo = vUrlhaciendaAuthApiDesarrollo
             * vUsuarioHacienda.urlhaciendaAuthApiProduccion = vUrlhaciendaAuthApiProduccion
             * vUsuarioHacienda.username = txtUsuarioHacienda.Text
             * vUsuarioHacienda.password = txtClaveHacienda.Text
             *
             * ' Genera Token
             * vReply = vServicioBLL.fGenerarToken(vUsuarioHacienda)
             *
             * If Not vReply.token Is Nothing Then
             * MessageBox.Show("Mensaje: " & vReply.msg & Chr(13) & _
             *              "Token: " & vReply.token.access_token)
             * Else
             * MessageBox.Show("Mensaje: " & vReply.msg & Chr(13) & "Token: NULL")
             * End If
             */
            return(vResponse);
        }