// GET /API/ProductSelector/ProductInfo [Route("ProductInfo")] [HttpGet] [ResponseType(typeof(IEnumerable))] public IHttpActionResult GetProductInfo(string productName, Guid productId, int siteId, EnumMasterListProductSource source, bool single = false) { try { if (productId == default(Guid)) { return BadRequest(); } var response = LogViewManager.LoadByProductId(productId); if (response == null) { return NotFound(); } if (!response.SiteId.HasValue && response.SiteId.IsNullOrWhiteSpace()) { return NotFound(); } var secondarySiteId = response.SiteId; if (!response.SiteId.HasValue) { var car = SiteSelectorManager.GetSiteList(response.SiteName, response.SiteId).OrderBy(x => x.SiteName).FirstOrDefault(); if (car != null) secondarySiteId = car.SiteId; } if (!response.SiteId.HasValue && !secondarySiteId.HasValue) { return NotFound(); } var result = ProductSelectorManager.GetListOfProducts(productName, response.SiteId).OrderBy(x => x.Name).ToList(); // If we pass the parameter for single, then return a single one. if (result.SafeAny()) { return Ok(single ? result.Take(1) : result.Take(10)); } return NotFound(); } catch (Exception ex) { ExceptionHandler.LogException(ex); return InternalServerError(new Exception(StringConstants.InternalServerError)); } }