using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net; using System.Threading.Tasks; using Dapper; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.JsonPatch; using Microsoft.AspNetCore.Mvc; using MisIngredientesVue.Core.Extensions; using MisIngredientesVue.Core.Models; using MisIngredientesVue.Core.Services; using Newtonsoft.Json; using Newtonsoft.Json.Linq; namespace MisIngredientesVue.Controllers { [Route("api/[controller]")] [ApiController] public class MarketplaceController : Controller { private readonly IMarketplaceService _marketplaceService; public MarketplaceController(IMarketplaceService marketplaceService) { _marketplaceService = marketplaceService; } [HttpGet] [Route("products")] public async Task SearchProducts(string term) { return Ok(await _marketplaceService.SearchProducts(term)); } [HttpGet] [Route("products/{id}")] public async Task GetProduct(int id) { return Ok(await _marketplaceService.GetProduct(id)); } [HttpPost] [Route("addproducttomylist/{id}")] public async Task AddProductToMyList(int id) { await _marketplaceService.AddProductToMyList(id); return Ok(); } [HttpGet] [Route("getmyproductlist")] public async Task GetMyProductList() { return Ok(await _marketplaceService.GetMyProductList()); } } }