using FHT.Core.Agency.Interfaces; using FHT.Core.Agency.Interfaces.Model; using IO.Swagger.Api; using System.Collections.Generic; using System.Linq; namespace FHT.Agency.Web.CommandServices { public class ProductService : IProductService { private readonly ProductApiApi _productApi; public ProductService(ProductApiApi prodictApi) { _productApi = prodictApi; string token = new AuthorizationService().Login(); _productApi.Configuration.AddDefaultHeader("Content-Type", "application/json"); _productApi.Configuration.AddDefaultHeader("Authorization", string.Format("bearer {0}", token)); } public List AutoCompleteSystemCategories(string q, int? id) { List categories = _productApi.ProductApiAutoCompleteSystemCategories(q, id); return categories.Select(c => new CategoryAutoCompleteViewModel { Key = c.Key.Value, Value = c.Value }).ToList(); } } }