public SingleProductResponse ReadSingleProduct(long productId) { SingleProductResponse singleProductResponse = new SingleProductResponse() { StatusCode = 200 }; try { if (productId == 0) { singleProductResponse.StatusCode = 400; singleProductResponse.ErrorList = new List <SingleProductValidationResponse>() { new SingleProductValidationResponse() { Code = 101, Message = "Invalid Product Id" } }; return(singleProductResponse); } Item item = _productLayer.ReadSingleProduct(productId); if (item != null) { singleProductResponse.Product = item; } else { singleProductResponse.StatusCode = 400; singleProductResponse.ErrorList = new List <SingleProductValidationResponse>() { new SingleProductValidationResponse() { Code = 101, Message = "Product Not Found" } }; } } catch (Exception ex) { singleProductResponse.StatusCode = 400; singleProductResponse.ErrorList = new List <SingleProductValidationResponse>() { new SingleProductValidationResponse() { Code = 101, Message = "Error While Retriving Product" + ex.Message } }; } return(singleProductResponse); }
public ActionResult <SingleProductResponse> Get(long productId) { SingleProductResponse response = _productBiz.ReadSingleProduct(productId); return(Ok(response)); }