public void ObtenerSucursalExisteTest() { sucursaldto.idSucursal = 1; Sucursal sucursal = sucursalService.ObtenerSucursal(sucursaldto); Assert.IsNotNull(sucursal); }
public IHttpActionResult versucursal([FromBody] SucursalDTO s) { try { Sucursal su = new Sucursal(); SucursalDTO suc = new SucursalDTO(); su = sucursalServicio.ObtenerSucursal(s); EmpresaDTO emm = new EmpresaDTO { idEmpresa = su.idEmpresa }; ImagenDTO i = new ImagenDTO() { idSucursal = su.idSucursal, principal = true }; suc.idSucursal = su.idSucursal; suc.nombre = su.nombreSucursal; suc.direccion = su.direccion; suc.idEmpresa = su.idEmpresa; suc.nombreEmpresa = empresaServicio.ObtenerEmpresa(emm).nombreEmpresa; suc.rutaimagen = imagenServicio.Obtenerimagen(i); return(Ok(RespuestaApi <SucursalDTO> .createRespuestaSuccess(suc, "success"))); } catch (Exception ex) { return(Ok(RespuestaApi <string> .createRespuestaError(ex.ToString(), "error"))); } }
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"))); } }
public IHttpActionResult verproducto([FromBody] ProductoDTO p) { try { Producto pro = new Producto(); ProductoDTO producto = new ProductoDTO(); pro = productoServicio.Obtenerproducto(p); List <EmpresaDTO> lempresas = new List <EmpresaDTO>(); List <SucursalDTO> lsucursales = new List <SucursalDTO>(); ProductoEmpresaDTO pe = new ProductoEmpresaDTO(); pe.idProducto = pro.idProducto; var prems = productoempresaServicio.obtenerProductosEmpresaByProductoID(pe); foreach (var pre in prems) { EmpresaDTO objempresa = new EmpresaDTO(); objempresa.idEmpresa = Convert.ToInt64(pre.idEmpresa); lempresas.Add(new EmpresaDTO() { idEmpresa = Convert.ToInt64(pre.idEmpresa), nombrempresa = empresaServicio.ObtenerEmpresa(objempresa).nombreEmpresa, idproductoempresa = pre.idProductoEmpresa }); } foreach (var e in lempresas) { ProductoSucursalDTO ps = new ProductoSucursalDTO(); ps.idProductoEmpresa = e.idproductoempresa; var prsus = productosucursalServicio.obtenerProductosSucursalByProductoEmpresaID(ps); foreach (var prs in prsus) { SucursalDTO objsucursal = new SucursalDTO(); objsucursal.idSucursal = Convert.ToInt64(prs.idSucursal); lsucursales.Add(new SucursalDTO() { idSucursal = Convert.ToInt64(prs.idSucursal), nombre = sucursalServicio.ObtenerSucursal(objsucursal).nombreSucursal, idProductoSucursal = prs.idProductoSucursal, idProductoEmpresa = prs.idProductoEmpresa, precioProductoSucursal = prs.precio }); } } CategoriaDTO c = new CategoriaDTO() { idCategoria = pro.idCategoria }; ImagenDTO i = new ImagenDTO() { idProducto = pro.idProducto, principal = true }; producto.nombre = pro.nombreProducto; producto.descripcionCorta = pro.descripcionCortaProducto; producto.descripcionLarga = pro.descripcionLargaProducto; producto.idCategoria = pro.idCategoria; producto.nombrecategoria = categoriaServicio.Obtenercategoria(c).nombreCategoria; producto.rutaimagen = imagenServicio.Obtenerimagen(i); producto.empresas = lempresas; producto.sucursales = lsucursales; return(Ok(RespuestaApi <ProductoDTO> .createRespuestaSuccess(producto, "success"))); } catch (Exception ex) { return(Ok(RespuestaApi <string> .createRespuestaError(ex.ToString(), "error"))); } }