public ACrust GetByCRUST(CRUSTS CRUST) { var dbCrust = context.DBCrusts.FirstOrDefault(crust => crust.CRUST == CRUST); if (dbCrust is null) { return(null); } return(mapperCrust.Map(dbCrust)); }
public IActionResult AddPizza(PIZZAS pizza, SIZES size, CRUSTS crust, List <TOPPINGS> topping) { var API = new ValuesApi(new Configuration { BasePath = "https://localhost:44368/" }); var fleshedOutPizza = API.ApiValuesPIZZASIZECRUSTGet(pizza, size, crust, topping); return(PizzaMenu(new List <APizza> { fleshedOutPizza })); }
public ActionResult <APizza> GetPizzaInfo(PIZZAS PIZZA, SIZES SIZE, CRUSTS CRUST, [FromQuery] List <TOPPINGS> TOPPING) { APizza pizza; ASize size; ACrust crust; List <ATopping> toppings = new List <ATopping>(); switch (SIZE) { case SIZES.SMALL: size = new SmallSize(); break; case SIZES.MEDIUM: size = new MediumSize(); break; case SIZES.LARGE: size = new LargeSize(); break; default: return(StatusCode(400, "Size not recognized")); } switch (CRUST) { case CRUSTS.DEEPDISH: crust = new DeepDishCrust(); break; case CRUSTS.STANDARD: crust = new StandardCrust(); break; case CRUSTS.STUFFED: crust = new StuffedCrust(); break; case CRUSTS.THIN: crust = new ThinCrust(); break; default: return(StatusCode(400, "Crust not recognized")); } foreach (TOPPINGS toppingEnum in TOPPING) { switch (toppingEnum) { case TOPPINGS.BACON: toppings.Add(new Bacon()); break; case TOPPINGS.CHICKEN: toppings.Add(new Chicken()); break; case TOPPINGS.EXTRACHEESE: toppings.Add(new ExtraCheese()); break; case TOPPINGS.GREENPEPPER: toppings.Add(new GreenPepper()); break; case TOPPINGS.HAM: toppings.Add(new Ham()); break; case TOPPINGS.NOCHEESE: toppings.Add(new NoCheese()); break; case TOPPINGS.PINEAPPLE: toppings.Add(new Pineapple()); break; case TOPPINGS.REDPEPPER: toppings.Add(new RedPepper()); break; case TOPPINGS.SAUSAGE: toppings.Add(new Sausage()); break; default: return(StatusCode(400, "Topping not recognized")); } } pizza = new APizza { PIZZA = PIZZA, Name = Enum.GetName <PIZZAS>(PIZZA), Crust = crust, Toppings = toppings }; switch (PIZZA) { case PIZZAS.MEAT: pizza = new MeatPizza(size); pizza.Crust = crust; pizza.Toppings = toppings; break; case PIZZAS.HAWAIIAN: pizza = new HawaiianPizza(size); pizza.Crust = crust; pizza.Toppings = toppings; break; case PIZZAS.VEGAN: pizza = new VeganPizza(size); pizza.Crust = crust; pizza.Toppings = toppings; break; case PIZZAS.CUSTOM: pizza = new CustomPizza(crust, size, toppings); break; default: return(StatusCode(400, "Size not recognized")); } pizza.CalculatePrice(); return(Ok(pizza)); }
/// <summary> /// /// </summary> /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="PIZZA"></param> /// <param name="SIZE"></param> /// <param name="CRUST"></param> /// <param name="TOPPING"> (optional)</param> /// <returns>Task of ApiResponse (APizza)</returns> public async System.Threading.Tasks.Task <ApiResponse <APizza> > ApiValuesPIZZASIZECRUSTGetAsyncWithHttpInfo(PIZZAS PIZZA, SIZES SIZE, CRUSTS CRUST, List <TOPPINGS> TOPPING = null) { // verify the required parameter 'PIZZA' is set if (PIZZA == null) { throw new ApiException(400, "Missing required parameter 'PIZZA' when calling ValuesApi->ApiValuesPIZZASIZECRUSTGet"); } // verify the required parameter 'SIZE' is set if (SIZE == null) { throw new ApiException(400, "Missing required parameter 'SIZE' when calling ValuesApi->ApiValuesPIZZASIZECRUSTGet"); } // verify the required parameter 'CRUST' is set if (CRUST == null) { throw new ApiException(400, "Missing required parameter 'CRUST' when calling ValuesApi->ApiValuesPIZZASIZECRUSTGet"); } var localVarPath = "/api/Values/{PIZZA}/{SIZE}/{CRUST}"; var localVarPathParams = new Dictionary <String, String>(); var localVarQueryParams = new List <KeyValuePair <String, String> >(); var localVarHeaderParams = new Dictionary <String, String>(this.Configuration.DefaultHeader); var localVarFormParams = new Dictionary <String, String>(); var localVarFileParams = new Dictionary <String, FileParameter>(); Object localVarPostBody = null; // to determine the Content-Type header String[] localVarHttpContentTypes = new String[] { }; String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); // to determine the Accept header String[] localVarHttpHeaderAccepts = new String[] { "text/plain", "application/json", "text/json" }; String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); if (localVarHttpHeaderAccept != null) { localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); } if (PIZZA != null) { localVarPathParams.Add("PIZZA", this.Configuration.ApiClient.ParameterToString(PIZZA)); // path parameter } if (SIZE != null) { localVarPathParams.Add("SIZE", this.Configuration.ApiClient.ParameterToString(SIZE)); // path parameter } if (CRUST != null) { localVarPathParams.Add("CRUST", this.Configuration.ApiClient.ParameterToString(CRUST)); // path parameter } if (TOPPING != null) { localVarQueryParams.AddRange(this.Configuration.ApiClient.ParameterToKeyValuePairs("multi", "TOPPING", TOPPING)); // query parameter } // make the HTTP request IRestResponse localVarResponse = (IRestResponse)await this.Configuration.ApiClient.CallApiAsync(localVarPath, Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarPathParams, localVarHttpContentType); int localVarStatusCode = (int)localVarResponse.StatusCode; if (ExceptionFactory != null) { Exception exception = ExceptionFactory("ApiValuesPIZZASIZECRUSTGet", localVarResponse); if (exception != null) { throw exception; } } return(new ApiResponse <APizza>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => string.Join(",", x.Value)), (APizza)this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(APizza)))); }
/// <summary> /// /// </summary> /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="PIZZA"></param> /// <param name="SIZE"></param> /// <param name="CRUST"></param> /// <param name="TOPPING"> (optional)</param> /// <returns>Task of APizza</returns> public async System.Threading.Tasks.Task <APizza> ApiValuesPIZZASIZECRUSTGetAsync(PIZZAS PIZZA, SIZES SIZE, CRUSTS CRUST, List <TOPPINGS> TOPPING = null) { ApiResponse <APizza> localVarResponse = await ApiValuesPIZZASIZECRUSTGetAsyncWithHttpInfo(PIZZA, SIZE, CRUST, TOPPING); return(localVarResponse.Data); }
/// <summary> /// /// </summary> /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="PIZZA"></param> /// <param name="SIZE"></param> /// <param name="CRUST"></param> /// <param name="TOPPING"> (optional)</param> /// <returns>APizza</returns> public APizza ApiValuesPIZZASIZECRUSTGet(PIZZAS PIZZA, SIZES SIZE, CRUSTS CRUST, List <TOPPINGS> TOPPING = null) { ApiResponse <APizza> localVarResponse = ApiValuesPIZZASIZECRUSTGetWithHttpInfo(PIZZA, SIZE, CRUST, TOPPING); return(localVarResponse.Data); }
/// <summary> /// Initializes a new instance of the <see cref="ACrust" /> class. /// </summary> /// <param name="name">name.</param> /// <param name="price">price.</param> /// <param name="id">id.</param> /// <param name="crust">crust.</param> public ACrust(string name = default(string), double?price = default(double?), int?id = default(int?), CRUSTS crust = default(CRUSTS)) { this.Name = name; this.Price = price; this.Id = id; this.Crust = crust; }