public IActionResult Get() { StringValues hearderValues; var firstValue = string.Empty; if (Request.Headers.TryGetValue("id", out hearderValues)) { firstValue = hearderValues.FirstOrDefault(); } long id = Convert.ToInt64(firstValue); var item = _repository.Find(id); if (item == null) { return(NotFound()); } var SelectedUser = _showroomerRepository.Find(item.ShowroomerId); Showroomer showroomer = new Showroomer(); showroomer = SelectedUser; showroomer.Showrooms = null; showroomer.Orders = null; showroomer.Vouchers = null; showroomer.Interactions = null; item.Showroomer = showroomer; var SelectedProduct = _productRepository.Find(item.ProductId); Product Product = new Product(); Product = SelectedProduct; Product.Showrooms = null; Product.Interactions = null; Product.Orders = null; Product.Images = null; item.Product = Product; // Unset variables that are unused SelectedUser = null; showroomer = null; SelectedProduct = null; Product = null; return(new ObjectResult(item)); }
public ShowroomItem Find(string id) { if (string.IsNullOrWhiteSpace(id)) { throw new ArgumentNullException("id"); } return(_repository.Find(id)); }