public GetAllBeverageItemsResponse GetAllBeverageItems(GetAllBeverageItemsRequest request) { var response = new GetAllBeverageItemsResponse { IsSuccessful = false, Message = "" }; try { // Query our Foods table in SQL Server. Convert to a List<Food>. var items = _context.Beverages.ToList(); // Handle null value conditionally. if (items != null) { response.IsSuccessful = true; response.BeverageItems = items; } else { response.Message = "Query returned null result."; } } catch (Exception ex) { response.Message = ex.ToString(); } return(response); }
public IActionResult GetAllBeverage() { var request = new GetAllBeverageItemsRequest(); var response = _beverageservice.GetAllBeverageItems(request); if (response.IsSuccessful) { return(Ok(response.BeverageItems)); } else { return(BadRequest(response.Message)); } }