Example #1
0
        public IHttpActionResult vercategorias()
        {
            try
            {
                List <CategoriaDTO> categorias = new List <CategoriaDTO>();
                var listca = categoriaServicio.Obtenercategorias();
                foreach (var e in listca)
                {
                    ImagenDTO i = new ImagenDTO()
                    {
                        idcategoria = e.idCategoria,
                        principal   = true
                    };
                    categorias.Add(new CategoriaDTO
                    {
                        idCategoria = e.idCategoria,
                        nombre      = e.nombreCategoria,
                        rutaimagen  = imagenServicio.Obtenerimagen(i)
                    });
                }

                return(Ok(RespuestaApi <List <CategoriaDTO> > .createRespuestaSuccess(categorias, "success")));
            }
            catch (Exception ex)
            {
                return(Ok(RespuestaApi <string> .createRespuestaError(ex.ToString(), "error")));
            }
        }
Example #2
0
        public IHttpActionResult verempresas()
        {
            try
            {
                List <EmpresaDTO> Empresas = new List <EmpresaDTO>();
                var listem = empresaServicio.ObtenerEmpresas();
                foreach (var e in listem)
                {
                    ImagenDTO i = new ImagenDTO()
                    {
                        idEmpresa = e.idEmpresa,
                        principal = true
                    };
                    Empresas.Add(new EmpresaDTO
                    {
                        idEmpresa    = e.idEmpresa,
                        nombrempresa = e.nombreEmpresa,
                        nit          = e.nit,
                        razon        = e.razonSocial,
                        direccion    = e.direccionCentral,
                        rutaimagen   = imagenServicio.Obtenerimagen(i)
                    });
                }

                return(Ok(RespuestaApi <List <EmpresaDTO> > .createRespuestaSuccess(Empresas, "success")));
            }
            catch (Exception ex)
            {
                return(Ok(RespuestaApi <string> .createRespuestaError(ex.ToString(), "error")));
            }
        }
Example #3
0
        public IHttpActionResult verproductos([FromBody] ProductoEmpresaDTO p)
        {
            try
            {
                List <ProductoEmpresaDTO> productos = new List <ProductoEmpresaDTO>();
                var listpro = productoempresaservico.Obtenerproductos(p);
                foreach (var pr in listpro)
                {
                    ProductoDTO pp = new ProductoDTO()
                    {
                        idProducto = pr.idProducto
                    };
                    long         idc = productoServicio.Obtenerproducto(pp).idCategoria;
                    CategoriaDTO c   = new CategoriaDTO()
                    {
                        idCategoria = idc
                    };
                    EmpresaDTO e = new EmpresaDTO()
                    {
                        idEmpresa = Convert.ToInt64(pr.idEmpresa)
                    };
                    ImagenDTO i = new ImagenDTO()
                    {
                        idProductoEmpresa = pr.idProductoEmpresa,
                        principal         = true
                    };
                    productos.Add(new ProductoEmpresaDTO
                    {
                        idProductoEmpresa = pr.idProductoEmpresa,
                        idProducto        = pr.idProducto,
                        precio            = Convert.ToDecimal(pr.Precio),
                        nombre            = productoServicio.Obtenerproducto(pp).nombreProducto,
                        idEmpresa         = Convert.ToInt64(pr.idEmpresa),
                        nombreEmpresa     = empresaSevicio.ObtenerEmpresa(e).nombreEmpresa,
                        idCategoria       = categoriaServicio.Obtenercategoria(
                            new CategoriaDTO()
                        {
                            idCategoria = productoServicio.Obtenerproducto(pp).idCategoria
                        }
                            ).idCategoria,
                        nombreCategoria = categoriaServicio.Obtenercategoria(
                            new CategoriaDTO()
                        {
                            idCategoria = productoServicio.Obtenerproducto(pp).idCategoria
                        }
                            ).nombreCategoria,
                        rutaimagen = imagenService.Obtenerimagen(i)
                    });
                }

                return(Ok(RespuestaApi <List <ProductoEmpresaDTO> > .createRespuestaSuccess(productos, "success")));
            }
            catch (Exception ex)
            {
                return(Ok(RespuestaApi <string> .createRespuestaError(ex.ToString(), "error")));
            }
        }
Example #4
0
        public IHttpActionResult versucursales([FromBody] SucursalDTO s)
        {
            try
            {
                List <SucursalDTO> Sucursales = new List <SucursalDTO>();
                var listsu = sucursalServicio.ObtenerSucursales(s);
                foreach (var e in listsu)
                {
                    EmpresaDTO emm = new EmpresaDTO
                    {
                        idEmpresa = e.idEmpresa
                    };
                    ImagenDTO i = new ImagenDTO()
                    {
                        idSucursal = e.idSucursal,
                        principal  = true
                    };
                    Sucursales.Add(new SucursalDTO
                    {
                        idSucursal    = e.idSucursal,
                        nombre        = e.nombreSucursal,
                        idEmpresa     = e.idEmpresa,
                        direccion     = e.direccion,
                        nombreEmpresa = empresaServicio.ObtenerEmpresa(emm).nombreEmpresa,
                        rutaimagen    = imagenServicio.Obtenerimagen(i),
                        abierto       = turnoServicio.comprobardisponibilidad(e.idSucursal)
                    });
                }

                return(Ok(RespuestaApi <List <SucursalDTO> > .createRespuestaSuccess(Sucursales, "success")));
            }
            catch (Exception ex)
            {
                return(Ok(RespuestaApi <string> .createRespuestaError(ex.ToString(), "error")));
            }
        }
Example #5
0
        public IHttpActionResult verproductos([FromBody] ProductoDTO p)
        {
            try
            {
                List <ProductoDTO> productos = new List <ProductoDTO>();
                var listpro = productoServicio.Obtenerproductos(p);
                foreach (var pr in listpro)
                {
                    CategoriaDTO c = new CategoriaDTO()
                    {
                        idCategoria = pr.idCategoria
                    };
                    ImagenDTO i = new ImagenDTO()
                    {
                        idProducto = pr.idProducto,
                        principal  = true
                    };
                    productos.Add(new ProductoDTO
                    {
                        idProducto       = pr.idProducto,
                        nombre           = pr.nombreProducto,
                        descripcionCorta = pr.descripcionCortaProducto,
                        descripcionLarga = pr.descripcionLargaProducto,
                        idCategoria      = pr.idCategoria,
                        nombrecategoria  = categoriaServicio.Obtenercategoria(c).nombreCategoria,
                        rutaimagen       = imagenServicio.Obtenerimagen(i)
                    });
                }

                return(Ok(RespuestaApi <List <ProductoDTO> > .createRespuestaSuccess(productos, "success")));
            }
            catch (Exception ex)
            {
                return(Ok(RespuestaApi <string> .createRespuestaError(ex.ToString(), "error")));
            }
        }
Example #6
0
        public IHttpActionResult verproductos([FromBody] ProductoSucursalDTO p)
        {
            try
            {
                List <ProductoSucursalDTO> productos = new List <ProductoSucursalDTO>();
                var listpro = productosucursalService.Obtenerproductos(p);
                foreach (var pr in listpro)
                {
                    ProductoEmpresaDTO ppe = new ProductoEmpresaDTO()
                    {
                        idProductoEmpresa = pr.idProductoEmpresa
                    };
                    long        idp = productoempresaservico.Obtenerproducto(ppe).idProducto;
                    ProductoDTO pp  = new ProductoDTO()
                    {
                        idProducto = idp
                    };
                    long         idc = productoServicio.Obtenerproducto(pp).idCategoria;
                    CategoriaDTO c   = new CategoriaDTO()
                    {
                        idCategoria = idc
                    };
                    SucursalDTO s = new SucursalDTO()
                    {
                        idSucursal = pr.idSucursal
                    };
                    long       ide = sucursalService.ObtenerSucursal(s).idEmpresa;
                    EmpresaDTO e   = new EmpresaDTO()
                    {
                        idEmpresa = ide
                    };
                    ImagenDTO i3 = new ImagenDTO()
                    {
                        idProductoSucursal = pr.idProductoSucursal,
                        principal          = true
                    };
                    ImagenDTO i2 = new ImagenDTO()
                    {
                        idProductoEmpresa = pr.idProductoEmpresa,
                        principal         = true
                    };
                    ImagenDTO i1 = new ImagenDTO()
                    {
                        idProducto = idp,
                        principal  = true
                    };
                    string imag1 = "";
                    string imag2 = "";
                    string imag3 = "";
                    if (string.IsNullOrEmpty(imagenService.Obtenerimagen(i1)))
                    {
                        if (string.IsNullOrEmpty(imagenService.Obtenerimagen(i2)))
                        {
                            if (string.IsNullOrEmpty(imagenService.Obtenerimagen(i3)))
                            {
                            }
                            else
                            {
                                imag1 = imagenService.Obtenerimagen(i3);
                            }
                        }
                        else
                        {
                            imag1 = imagenService.Obtenerimagen(i2);
                            if (string.IsNullOrEmpty(imagenService.Obtenerimagen(i3)))
                            {
                            }
                            else
                            {
                                imag2 = imagenService.Obtenerimagen(i3);
                            }
                        }
                    }
                    else
                    {
                        imag1 = imagenService.Obtenerimagen(i1);
                        if (string.IsNullOrEmpty(imagenService.Obtenerimagen(i2)))
                        {
                            if (string.IsNullOrEmpty(imagenService.Obtenerimagen(i3)))
                            {
                            }
                            else
                            {
                                imag2 = imagenService.Obtenerimagen(i3);
                            }
                        }
                        else
                        {
                            imag2 = imagenService.Obtenerimagen(i2);
                            if (string.IsNullOrEmpty(imagenService.Obtenerimagen(i3)))
                            {
                            }
                            else
                            {
                                imag3 = imagenService.Obtenerimagen(i3);
                            }
                        }
                    }
                    productos.Add(new ProductoSucursalDTO
                    {
                        idProductoSucursal = pr.idProductoSucursal,
                        idProductoEmpresa  = pr.idProductoEmpresa,
                        idProducto         = pp.idProducto,
                        precio             = Convert.ToDecimal(pr.precio),
                        nombre             = productoServicio.Obtenerproducto(pp).nombreProducto,
                        idEmpresa          = Convert.ToInt64(ide),
                        nombreEmpresa      = empresaSevicio.ObtenerEmpresa(e).nombreEmpresa,
                        idCategoria        = categoriaServicio.Obtenercategoria(
                            new CategoriaDTO()
                        {
                            idCategoria = productoServicio.Obtenerproducto(pp).idCategoria
                        }
                            ).idCategoria,
                        nombreCategoria = categoriaServicio.Obtenercategoria(
                            new CategoriaDTO()
                        {
                            idCategoria = productoServicio.Obtenerproducto(pp).idCategoria
                        }
                            ).nombreCategoria,
                        idSucursal       = s.idSucursal,
                        nombreSucursal   = sucursalService.ObtenerSucursal(s).nombreSucursal,
                        descripcionCorta = productoServicio.Obtenerproducto(pp).descripcionCortaProducto,
                        descripcionLarga = productoServicio.Obtenerproducto(pp).descripcionLargaProducto,
                        rutaimagen1      = imag1,
                        rutaimagen2      = imag2,
                        rutaimagen3      = imag3,
                    });
                }

                return(Ok(RespuestaApi <List <ProductoSucursalDTO> > .createRespuestaSuccess(productos, "success")));
            }
            catch (Exception ex)
            {
                return(Ok(RespuestaApi <string> .createRespuestaError(ex.ToString(), "error")));
            }
        }