public IActionResult GetSupplierById(int id)
        {
            KeyValuePair <string, StringValues>[]
                requestHeaders = _ctxAccessor.HttpContext.Request.Headers.ToArray();
            var headerValues   = HttpHeadersHelper.ExtractHeaders(requestHeaders);

            HttpHeadersHelper.DisplayHeaders(headerValues);
            return(Ok(_seeder.Suppliers.FirstOrDefault(s => s.Id == id)));
        }
        public IActionResult GetProducts()
        {
            KeyValuePair <string, StringValues>[]
                requestHeaders = _ctxAccessor.HttpContext.Request.Headers.ToArray();
            var headerValues   = HttpHeadersHelper.ExtractHeaders(requestHeaders);

            HttpHeadersHelper.DisplayHeaders(headerValues);
            return(Ok(_seeder.Products));
        }
        public IActionResult DeleteSupplier(int id)
        {
            KeyValuePair <string, StringValues>[]
                requestHeaders = _ctxAccessor.HttpContext.Request.Headers.ToArray();
            var headerValues   = HttpHeadersHelper.ExtractHeaders(requestHeaders);

            HttpHeadersHelper.DisplayHeaders(headerValues);
            _seeder.Suppliers.RemoveAt(_seeder.Suppliers.IndexOf(_seeder.Suppliers.FirstOrDefault(s => s.Id == id)));
            return(Ok("supplier deleted"));
        }
        public IActionResult CreateSupplier([FromBody] Supplier supplier)
        {
            KeyValuePair <string, StringValues>[]
                requestHeaders = _ctxAccessor.HttpContext.Request.Headers.ToArray();
            var headerValues   = HttpHeadersHelper.ExtractHeaders(requestHeaders);

            HttpHeadersHelper.DisplayHeaders(headerValues);
            _seeder.Suppliers.Add(supplier);
            return(CreatedAtRoute("GetSupplierById", new { id = supplier.Id }, supplier));
        }
        public IActionResult CreateProduct([FromBody] Product product)
        {
            KeyValuePair <string, StringValues>[]
                requestHeaders = _ctxAccessor.HttpContext.Request.Headers.ToArray();
            var headerValues   = HttpHeadersHelper.ExtractHeaders(requestHeaders);

            HttpHeadersHelper.DisplayHeaders(headerValues);
            _seeder.Products.Add(product);
            return(CreatedAtRoute("GetProductById", new{ id = product.Id }, product));
        }
        public IActionResult DeleteProduct(int id)
        {
            KeyValuePair <string, StringValues>[]
                requestHeaders = _ctxAccessor.HttpContext.Request.Headers.ToArray();
            var headerValues   = HttpHeadersHelper.ExtractHeaders(requestHeaders);

            HttpHeadersHelper.DisplayHeaders(headerValues);
            var toRemove = _seeder.Products.FirstOrDefault(p => p.Id == id);

            _seeder.Products.Remove(toRemove);
            return(Ok("Product deleted"));
        }
        public IActionResult UpdateSupplier([FromBody] Supplier supplier, int id)
        {
            KeyValuePair <string, StringValues>[]
                requestHeaders = _ctxAccessor.HttpContext.Request.Headers.ToArray();
            var headerValues   = HttpHeadersHelper.ExtractHeaders(requestHeaders);

            HttpHeadersHelper.DisplayHeaders(headerValues);
            var toUpdate = _seeder.Suppliers.FirstOrDefault(s => s.Id == id);

            toUpdate.Name    = supplier.Name;
            toUpdate.Country = supplier.Country;
            return(Ok("Supplier updated"));
        }
        public IActionResult UpdateProduct([FromBody] Product product, int id)
        {
            KeyValuePair <string, StringValues>[]
                requestHeaders = _ctxAccessor.HttpContext.Request.Headers.ToArray();
            var headerValues   = HttpHeadersHelper.ExtractHeaders(requestHeaders);

            HttpHeadersHelper.DisplayHeaders(headerValues);
            var existing = _seeder.Products.FirstOrDefault(p => p.Id == id);

            existing.Code        = product.Code;
            existing.Description = product.Description;
            existing.Name        = product.Name;
            existing.Price       = product.Price;
            return(Ok("Product updated"));
        }