public GetProductModelResponse GetProductByID(int ID) { GetProductModelResponse response = new GetProductModelResponse(); try { Product product = _repositoryProduct.Get(t => t.ID == ID).SingleOrDefault(); response.GetProductModel = new GetProductModel { ID = product.ID, AvailableCount = product.AvailableCount, CategoryID = product.CategoryID, Color = product.Color, Description = product.Description, isActive = product.isActive, Price = product.Price, ProductName = product.ProductName, Size = product.Size, BrandID = product.BrandID }; foreach (ProductImage item in product.ProductImages) { response.GetProductModel.ImageUrls.Add(item.URL); } response.SetStatus(Constants.ResponseCode.SUCCESS); return(response); } catch (Exception) { response.SetStatus(Constants.ResponseCode.FAILED_ON_DB_PROCESS); return(response); } }
public IActionResult GetProductByID([FromBody] int ID) { GetProductModelResponse response = _service.GetProductByID(ID); return(response.Code != (int)Constants.ResponseCode.SUCCESS ? StatusCode(500, response) : StatusCode(200, response)); }