public async Task <ProductosForIndex2VM> GetProducto() { List <ProductoCategoria> listaProductosCategorias = await _productoCategoriasService.GetProductosCategorias(); List <Categoria> listaCategorias = await _categoriasService.GetCategorias(); ProductosForIndex2VM productosForIndex2VMs = await _productosService.GetProductosForIndex2(listaCategorias, listaProductosCategorias); return(productosForIndex2VMs); }
public async Task <ActionResult <List <Categoria> > > GetAllCategorias() { List <Categoria> listaCategorias = await _categoriasService.GetCategorias(); return(Ok(listaCategorias)); }
// GET: GustoUsuarios/Create public async Task <IActionResult> Create() { ViewData["CategoriaId"] = new SelectList(await _categoriasService.GetCategorias(), "Id", "Nombre"); ViewData["UsuarioId"] = new SelectList(await _usuariosService.GetUsuariosListByActiveIdentityUser(_userManager.GetUserId(User)), "Id", "NombreUsuario"); return(View()); }
// GET: ProductoCategorias/Create public async Task <IActionResult> Create() { ViewData["CategoriaId"] = new SelectList(await _categoriasService.GetCategorias(), "Id", "Nombre"); ViewData["ProductoId"] = new SelectList(await _productosService.GetProductos(), "Id", "Descripcion"); return(View()); }
// GET: Categorias public async Task <IActionResult> Index() { return(View(await _categoriasService.GetCategorias())); }
public async Task <IActionResult> Index2(string postalCode) { if (string.IsNullOrEmpty(postalCode)) { if (string.IsNullOrEmpty(HttpContext.Session.GetString("sessionPostalCode"))) { string postalCodeFromIP = await _helperService.GetPostalCodeFromIP(); string cityAndRegionFromIP = await _helperService.GetCityAndRegionFromIP(); HttpContext.Session.SetString("sessionPostalCode", postalCodeFromIP); HttpContext.Session.SetString("sessionCity", cityAndRegionFromIP); } } else { HttpContext.Session.SetString("sessionPostalCode", postalCode); string cityFromPostalCode = await _helperService.GetCityFromPostalCode(postalCode); HttpContext.Session.SetString("sessionCity", cityFromPostalCode); } string cp = HttpContext.Session.GetString("sessionPostalCode"); string city = HttpContext.Session.GetString("sessionCity"); ViewData["PostalCode"] = cp; ViewData["City"] = city; List <Categoria> listaCategorias; List <ProductoCategoria> listaProductosCategorias; ProductosForIndex2VM listasListaProductos; if (!_memoryCache.TryGetValue("ProductosForIndex2", out listasListaProductos)) { listaCategorias = await _categoriasService.GetCategorias(); listaProductosCategorias = await _productoCategoriasService.GetProductosCategorias(); listasListaProductos = await _productosService.GetProductosForIndex2(listaCategorias, listaProductosCategorias); _memoryCache.Set("Categorias", listaCategorias); _memoryCache.Set("ProductosForIndex2", listasListaProductos); } else { listasListaProductos = _memoryCache.Get("ProductosForIndex2") as ProductosForIndex2VM; } if (!_memoryCache.TryGetValue("Categorias", out listaCategorias)) { listaCategorias = await _categoriasService.GetCategorias(); _memoryCache.Set("Categorias", listaCategorias); } else { listaCategorias = _memoryCache.Get("Categorias") as List <Categoria>; } ViewData["Categorias"] = listaCategorias; return(View(listasListaProductos)); }