using Microsoft.AspNetCore.Mvc; using System.Reflection.Metadata; using TIAMWebApp.Shared.Application.Models; namespace TIAMWebApp.Server.Controllers { [ApiController] [Route("[controller]")] public class SupplierAPIController : ControllerBase { private static readonly Supplier[] suppliers = new Supplier[] { new Supplier(1, "Upgen Ltd.", "Sándor Kovács", "Mr", "Váci street 132", "Budapest", "Budapest", "1136", "Hungary", "+36701234567", "+3611234567", "https://www.upgen.hu"), new Supplier(2, "Kiraly Ltd.", "Elemér Kiraly", "Mr", "Andrássy street 37", "Budapest", "Budapest", "1066", "Hungary", "+36701234567", "+3611234567", "https://www.kiraly.hu"), //generate 9 new suppliers with different homepage url, companyname, contactname, city, address and postalcode new Supplier(3, "Király Ltd.", "Elemér Király", "Mr", "Andrássy street 37", "Budapest", "Budapest", "1066", "Hungary", "+36701234567", "+3611234567", "https://www.kiraly.hu"), new Supplier(4, "Király Ltd.", "Elemér Király", "Mr", "Andrássy street 37", "Budapest", "Budapest", "1066", "Hungary", "+36701234567", "+3611234567", "https://www.kiraly.hu"), new Supplier(5, "Király Ltd.", "Elemér Király", "Mr", "Andrássy street 37", "Budapest", "Budapest", "1066", "Hungary", "+36701234567", "+3611234567", "https://www.kiraly.hu"), new Supplier(6, "Király Ltd.", "Elemér Király", "Mr", "Andrássy street 37", "Budapest", "Budapest", "1066", "Hungary", "+36701234567", "+3611234567", "https://www.kiraly.hu"), new Supplier(7, "Király Ltd.", "Elemér Király", "Mr", "Andrássy street 37", "Budapest", "Budapest", "1066", "Hungary", "+36701234567", "+3611234567", "https://www.kiraly.hu"), new Supplier(8, "Király Ltd.", "Elemér Király", "Mr", "Andrássy street 37", "Budapest", "Budapest", "1066", "Hungary", "+36701234567", "+3611234567", "https://www.kiraly.hu"), new Supplier(9, "Király Ltd.", "Elemér Király", "Mr", "Andrássy street 37", "Budapest", "Budapest", "1066", "Hungary", "+36701234567", "+3611234567", "https://www.kiraly.hu"), new Supplier(10, "Király Ltd.", "Elemér Király", "Mr", "Andrássy street 37", "Budapest", "Budapest", "1066", "Hungary", "+36701234567", "+3611234567", "https://www.kiraly.hu"), new Supplier(11, "Király Ltd.", "Elemér Király", "Mr", "Andrássy street 37", "Budapest", "Budapest", "1066", "Hungary", "+36701234567", "+3611234567", "https://www.kiraly.hu"), }; private ProductDTO[] GetMockProducts(int SupplierId) { return Products.Where(p => p.SupplierId == SupplierId).ToArray(); } private static readonly ProductDTO[] Products = new ProductDTO[] { new ProductDTO{ Id = 1, ProductName = "Product1", SupplierId = 1, CategoryId = 1}, new ProductDTO{ Id = 2, ProductName = "Product2", SupplierId = 1, CategoryId = 3}, new ProductDTO{ Id = 3, ProductName = "Product3", SupplierId = 1, CategoryId = 7}, new ProductDTO{ Id = 4, ProductName = "Product4", SupplierId = 2, CategoryId = 1}, new ProductDTO{ Id = 5, ProductName = "Product5", SupplierId = 2, CategoryId = 2}, new ProductDTO{ Id = 6, ProductName = "Product6", SupplierId = 2, CategoryId = 3}, new ProductDTO{ Id = 7, ProductName = "Product7", SupplierId = 3, CategoryId = 4}, new ProductDTO{ Id = 8, ProductName = "Product8", SupplierId = 3, CategoryId = 5}, new ProductDTO{ Id = 9, ProductName = "Product9", SupplierId = 3, CategoryId = 6}, new ProductDTO{ Id = 10, ProductName = "Product10", SupplierId = 4, CategoryId = 7}, new ProductDTO{ Id = 11, ProductName = "Product11", SupplierId = 4, CategoryId = 3}, new ProductDTO{ Id = 12, ProductName = "Product12", SupplierId = 4, CategoryId = 6}, new ProductDTO{ Id = 13, ProductName = "Product13", SupplierId = 5, CategoryId = 5}, new ProductDTO{ Id = 14, ProductName = "Product14", SupplierId = 5, CategoryId = 1}, new ProductDTO{ Id = 15, ProductName = "Product15", SupplierId = 5, CategoryId = 8}, new ProductDTO{ Id = 16, ProductName = "Product16", SupplierId = 6, CategoryId = 6}, new ProductDTO{ Id = 17, ProductName = "Product17", SupplierId = 6, CategoryId = 6}, new ProductDTO{ Id = 18, ProductName = "Product18", SupplierId = 6, CategoryId = 9}, new ProductDTO{ Id = 19, ProductName = "Product19", SupplierId = 7, CategoryId = 3}, new ProductDTO{ Id = 20, ProductName = "Product20", SupplierId = 7, CategoryId = 2}, new ProductDTO{ Id = 21, ProductName = "Product21", SupplierId = 7, CategoryId = 1}, new ProductDTO{ Id = 22, ProductName = "Product22", SupplierId = 8, CategoryId = 4}, new ProductDTO{ Id = 23, ProductName = "Product23", SupplierId = 8, CategoryId = 5}, new ProductDTO{ Id = 24, ProductName = "Product24", SupplierId = 8, CategoryId = 6}, new ProductDTO{ Id = 25, ProductName = "Product25", SupplierId = 9, CategoryId = 7}, new ProductDTO{ Id = 26, ProductName = "Product26", SupplierId = 9, CategoryId = 3}, new ProductDTO{ Id = 27, ProductName = "Product27", SupplierId = 9, CategoryId = 6}, new ProductDTO{ Id = 28, ProductName = "Product28", SupplierId = 10, CategoryId = 5}, new ProductDTO{ Id = 29, ProductName = "Product29", SupplierId = 10, CategoryId = 1}, new ProductDTO{ Id = 30, ProductName = "Product30", SupplierId = 10, CategoryId = 8}, new ProductDTO{ Id = 31, ProductName = "Product31", SupplierId = 11, CategoryId = 6}, new ProductDTO{ Id = 32, ProductName = "Product32", SupplierId = 11, CategoryId = 6}, }; private readonly ILogger _logger; public SupplierAPIController(ILogger logger) { _logger = logger; } [HttpGet] public IEnumerable Get() { foreach (var supplier in suppliers) { supplier.Products = GetMockProducts(supplier.SupplierId); } return suppliers; } } }