Beispiel #1
0
        public IndexViewModel(IConfiguration configuration)
        {
            var ad = new AdaptadorAtc(configuration);

            Vehiculos = ad.TiposVehiculoLeer(null);
            var res = ad.ArticulosLeerUnClick();

            UnClick   = res.UnClick;
            Novedades = res.Novedades;
            streaming = configuration.GetSection("StreamFiles")["rutaStreaming"];
            foreach (TipoVehiculo vh in Vehiculos)
            {
                vh.url = streaming + vh.Imagen;
            }
            ;
            if (Novedades.Count > 0)
            {
                Novedades[0].active = true;
            }
        }
        public IActionResult EliminarArticulo(int IDUsuario, int IDArticulo, Boolean EnProcesar)
        {
            ObjectResult result;

            try
            {
                var ad = new AdaptadorAtc(_configuration);
                _carrito = ad.CarritosUsuariosEliminarArticulo(IDUsuario, IDArticulo, EnProcesar);
                result   = new ObjectResult(_carrito)
                {
                    StatusCode = (int)HttpStatusCode.OK
                };
            }
            catch (Exception ex)
            {
                result = new ObjectResult(ex)
                {
                    StatusCode = (int)HttpStatusCode.Conflict
                };
                Request.HttpContext.Response.Headers.Add("dsError", ex.Message);
            }
            return(result);
        }
        public IActionResult PedidosCrear(int idUsuarioWeb, int idDomiEnt)
        {
            var          ad = new AdaptadorAtc(_configuration);
            ObjectResult result;

            try
            {
                ad.PedidosCrear(idUsuarioWeb, idDomiEnt);
                result = new ObjectResult(1)
                {
                    StatusCode = (int)HttpStatusCode.OK
                };
            }
            catch (Exception ex)
            {
                result = new ObjectResult(ex)
                {
                    StatusCode = (int)HttpStatusCode.Conflict
                };
                Request.HttpContext.Response.Headers.Add("dsError", ex.Message);
            }
            return(result);
        }
        public IActionResult AnosLeerPor(int idmodelocarroceria, int idfamilia)
        {
            ObjectResult result;
            var          ad = new AdaptadorAtc(_configuration);

            try
            {
                var res = ad.AnosLeerPor(idmodelocarroceria, idfamilia);
                result = new ObjectResult(res)
                {
                    StatusCode = (int)HttpStatusCode.OK
                };
            }
            catch (Exception ex)
            {
                result = new ObjectResult(ex)
                {
                    StatusCode = (int)HttpStatusCode.Conflict
                };
                Request.HttpContext.Response.Headers.Add("dsError", ex.Message);
            }
            return(result);
        }
        public IActionResult ArticulosBusquedaPaginada([FromBody] CampoBusqueda cadena)
        {
            var          ad = new AdaptadorAtc(_configuration);
            ObjectResult result;

            try
            {
                var res = new ProductosViewModel(_configuration, cadena);
                result = new ObjectResult(res)
                {
                    StatusCode = (int)HttpStatusCode.OK
                };
            }
            catch (Exception ex)
            {
                result = new ObjectResult(ex)
                {
                    StatusCode = (int)HttpStatusCode.Conflict
                };
                Request.HttpContext.Response.Headers.Add("dsError", ex.Message);
            }
            return(result);
        }
        public IActionResult ArticulosLeerPorCadena(string cadena)
        {
            var          ad = new AdaptadorAtc(_configuration);
            ObjectResult result;

            try
            {
                var res = ad.ArticulosLeerPorCadena(cadena);
                result = new ObjectResult(res)
                {
                    StatusCode = (int)HttpStatusCode.OK
                };
            }
            catch (Exception ex)
            {
                result = new ObjectResult(ex)
                {
                    StatusCode = (int)HttpStatusCode.Conflict
                };
                Request.HttpContext.Response.Headers.Add("dsError", ex.Message);
            }
            return(result);
        }
Beispiel #7
0
        public VehiculosViewModel(IConfiguration configuration, int?id, Parametros pr)
        {
            var ad = new AdaptadorAtc(configuration);

            Vehiculos = ad.TiposVehiculoLeer(id);
            streaming = configuration.GetSection("StreamFiles")["rutaStreaming"];
            foreach (TipoVehiculo vh in Vehiculos)
            {
                vh.url = streaming + vh.Imagen;
                if (vh.IDTipoVehiculo == id)
                {
                    VehiculoSeleccionado = vh;
                }
            }
            ;
            IDTipoVehiculo = id;
            if (pr != null)
            {
                var res = ad.ObtenerdescripcionesPorIDs(pr);
                Parametros = res;
                JavaScriptSerializer js = new JavaScriptSerializer();
                ParametrosJavascript = js.Serialize(res);
            }
        }
        public IActionResult FacturasLeer(int idCliente, int pagina, int bloque, string nFactura, DateTime?fechaDesde, DateTime?fechaHasta)
        {
            ObjectResult result;
            var          ad = new AdaptadorAtc(_configuration);

            try
            {
                //var res = new LecturasViewModel(_configuration, bs);
                var res = ad.FacturasLeer(idCliente, pagina, bloque, nFactura, fechaDesde, fechaHasta);
                result = new ObjectResult(res)
                {
                    StatusCode = (int)HttpStatusCode.OK
                };
            }
            catch (Exception ex)
            {
                result = new ObjectResult(ex)
                {
                    StatusCode = (int)HttpStatusCode.Conflict
                };
                Request.HttpContext.Response.Headers.Add("dsError", ex.Message);
            }
            return(result);
        }
        public IActionResult CarroceriasLeerEsquema(int idmodelocarroceria, int ano)
        {
            ObjectResult result;
            var          ad = new AdaptadorAtc(_configuration);

            try
            {
                var carr = ad.CarroceriasLeerEsquema(idmodelocarroceria, ano);
                var res  = new EsquemaViewModel(carr);
                result = new ObjectResult(res)
                {
                    StatusCode = (int)HttpStatusCode.OK
                };
            }
            catch (Exception ex)
            {
                result = new ObjectResult(ex)
                {
                    StatusCode = (int)HttpStatusCode.Conflict
                };
                Request.HttpContext.Response.Headers.Add("dsError", ex.Message);
            }
            return(result);
        }
        public IActionResult FinanzasEfectosCursoLeer(int iddeudor, int bloque, int pagina)
        {
            ObjectResult result;
            var          ad = new AdaptadorAtc(_configuration);

            try
            {
                //var res = new LecturasViewModel(_configuration, bs);
                var res = ad.FinanzasEfectosCursoLeer(iddeudor, bloque, pagina);
                result = new ObjectResult(res)
                {
                    StatusCode = (int)HttpStatusCode.OK
                };
            }
            catch (Exception ex)
            {
                result = new ObjectResult(ex)
                {
                    StatusCode = (int)HttpStatusCode.Conflict
                };
                Request.HttpContext.Response.Headers.Add("dsError", ex.Message);
            }
            return(result);
        }
        public IActionResult PedidosMensualesLeer(int idcliente)
        {
            ObjectResult result;
            var          ad = new AdaptadorAtc(_configuration);

            try
            {
                //var res = new LecturasViewModel(_configuration, bs);
                var res = ad.EsquemasMensualesLeer(idcliente, "Pedidos");
                result = new ObjectResult(res)
                {
                    StatusCode = (int)HttpStatusCode.OK
                };
            }
            catch (Exception ex)
            {
                result = new ObjectResult(ex)
                {
                    StatusCode = (int)HttpStatusCode.Conflict
                };
                Request.HttpContext.Response.Headers.Add("dsError", ex.Message);
            }
            return(result);
        }
        public IActionResult ModelosLeer(int?IDTipoVehiculo, int IDSeccion)
        {
            ObjectResult result;
            var          ad = new AdaptadorAtc(_configuration);

            try
            {
                //var res = new LecturasViewModel(_configuration, bs);
                var res = ad.ModelosLeer(IDTipoVehiculo, IDSeccion);
                result = new ObjectResult(res)
                {
                    StatusCode = (int)HttpStatusCode.OK
                };
            }
            catch (Exception ex)
            {
                result = new ObjectResult(ex)
                {
                    StatusCode = (int)HttpStatusCode.Conflict
                };
                Request.HttpContext.Response.Headers.Add("dsError", ex.Message);
            }
            return(result);
        }
Beispiel #13
0
        public IActionResult SubirExcel([FromForm] FormularioExcel a)
        {
            ViewData["Api"] = _endPoint;
            var us = HttpContext.Session.GetObjectFromJson <UsuarioWeb>("Login");

            if (!ComprobarLogin())
            {
                return(RedirectToAction(_defaultPage, _defaultController));
            }
            else
            {
                ViewData["Usuario"] = HttpContext.Session.GetObjectFromJson <UsuarioWeb>("Login");
            }
            var msj = new List <MensajeError>();
            var res = new List <ArticuloBasico>();

            if (a.files != null)
            {
                try
                {
                    using (var ms = new MemoryStream())
                    {
                        a.files.CopyTo(ms);
                        var    fileBytes = ms.ToArray();
                        string s         = Convert.ToBase64String(fileBytes);
                        // act on the Base64 data

                        using (ExcelPackage package = new ExcelPackage(ms))
                        {
                            ExcelWorksheet worksheet  = package.Workbook.Worksheets[0];
                            int            rowCount   = worksheet.Dimension.Rows;
                            int            ColCount   = worksheet.Dimension.Columns;
                            bool           bHeaderRow = true;
                            for (int row = 1; row <= rowCount; row++)
                            {
                                if (bHeaderRow)
                                {
                                    bHeaderRow = false;
                                }
                                else
                                {
                                    var ar = new ArticuloBasico();
                                    //bool eurocode = true;
                                    if (worksheet.Cells[row, 1].Value != null)
                                    {
                                        var r = worksheet.Cells["C1"].Start;
                                        ar.Descripcion = worksheet.Cells[row, 1].Value.ToString();
                                        if (worksheet.Cells[row, 2].Value != null)
                                        {
                                            ar.Cantidad = worksheet.Cells[row, 2].Value.ToString();
                                        }
                                        else
                                        {
                                            ar.Cantidad = "1";
                                        }
                                        res.Add(ar);
                                    }

                                    /*for (int col = 1; col <= ColCount; col++)
                                     * {
                                     *  if (eurocode)
                                     *  {
                                     *      ar.Descripcion = worksheet.Cells[row, col].Value.ToString();
                                     *      eurocode = false;
                                     *  }
                                     *  else
                                     *  {
                                     *      ar.Cantidad = worksheet.Cells[row, col].Value.ToString();
                                     *      //sb.Append(worksheet.Cells[row, col].Value.ToString() + "\t");
                                     *  }
                                     * }*/
                                }
                            }
                            var i = 1;
                        }
                    }
                }
                catch (Exception ex)
                {
                    msj.Add(new MensajeError {
                        Descripcion = "Archivo no válido", Estado = 2
                    });
                }

                if (res.Count > 0)
                {
                    var ad = new AdaptadorAtc(_configuration);
                    msj = ad.CarritosUsuariosAnadirMasivamente(res, a.vaciar, us.IdUsuarioWeb);
                }
                else
                {
                    msj.Add(new MensajeError {
                        Descripcion = "Excel vacío", Estado = 2
                    });
                }
            }
            else
            {
                msj.Add(new MensajeError {
                    Descripcion = "Archivo no válido", Estado = 2
                });
            }



            ViewData["Mensajes"] = msj;
            return(View());
        }