Exemple #1
0
        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
            }));
        }
Exemple #2
0
 public static void ModificarPizza(PIZZAS pizza)
 {
     using (var model2 = new Model2())
     {
         // modificacion
         PIZZAS pizzaAntigua = model2.PIZZAS
                               .Where(p => p.IDPIZZA == pizza.IDPIZZA).FirstOrDefault();
         pizzaAntigua.PRECIO = pizza.PRECIO;
         pizzaAntigua.IMAGEN = pizza.IMAGEN;
         pizzaAntigua.TITULO = pizza.TITULO;
         model2.SaveChanges();
     }
 }
        private decimal calcularValorTotal(PIZZAS pizza)
        {
            var valorTotal = 0m;

            valorTotal = pizza.TAMANHOS.VALOR;

            foreach (var adicionalPizza in pizza.PIZZA_ADICIONAIS)
            {
                var adicional = db.ADICIONAIS.First(r => r.ID == adicionalPizza.ADICIONALID);
                valorTotal += adicional.VALOR;
            }

            return(valorTotal);
        }
        private int calcularTempoPreparo(PIZZAS pizza)
        {
            var tempoPreparo = 0;

            tempoPreparo  = pizza.TAMANHOS.TEMPOPREPARO;
            tempoPreparo += pizza.SABORES.TEMPOADICIONAL;

            foreach (var adicionalPizza in pizza.PIZZA_ADICIONAIS)
            {
                var adicional = db.ADICIONAIS.First(r => r.ID == adicionalPizza.ADICIONALID);
                tempoPreparo += adicional.TEMPOADICIONAL;
            }

            return(tempoPreparo);
        }
        public ActionResult <APizza> GetPizzaInfo(PIZZAS PIZZA, SIZES SIZE)
        {
            APizza pizza;
            ASize  size;

            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 (PIZZA)
            {
            case PIZZAS.MEAT:
                pizza = new MeatPizza(size);
                break;

            case PIZZAS.HAWAIIAN:
                pizza = new HawaiianPizza(size);
                break;

            case PIZZAS.VEGAN:
                pizza = new VeganPizza(size);
                break;

            case PIZZAS.CUSTOM:
                return(StatusCode(400, "You entered a custom pizza without providing the crust or toppings"));

            default:
                return(StatusCode(400, "Size not recognized"));
            }

            pizza.CalculatePrice();
            return(Ok(pizza));
        }
Exemple #6
0
        public IHttpActionResult CriarPizza(int tamanho, int sabor)
        {
            if (!db.TAMANHOS.Any(r => r.ID == tamanho))
            {
                return(BadRequest("O tamanho informado está incorreto."));
            }

            if (!db.SABORES.Any(r => r.ID == sabor))
            {
                return(BadRequest("O sabor informado está incorreto."));
            }

            var pizza = new PIZZAS()
            {
                SABOR   = sabor,
                TAMANHO = tamanho
            };

            db.PIZZAS.Add(pizza);

            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = pizza.ID }, pizza));
        }
        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));
        }
Exemple #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="APizza" /> class.
 /// </summary>
 /// <param name="name">name.</param>
 /// <param name="crust">crust.</param>
 /// <param name="size">size.</param>
 /// <param name="toppings">toppings.</param>
 /// <param name="price">price.</param>
 /// <param name="pizza">pizza.</param>
 /// <param name="id">id.</param>
 public APizza(string name = default(string), ACrust crust = default(ACrust), ASize size = default(ASize), List <ATopping> toppings = default(List <ATopping>), double?price = default(double?), PIZZAS pizza = default(PIZZAS), int?id = default(int?))
 {
     this.Name     = name;
     this.Crust    = crust;
     this.Size     = size;
     this.Toppings = toppings;
     this.Price    = price;
     this.Pizza    = pizza;
     this.Id       = id;
 }
        /// <summary>
        ///
        /// </summary>
        /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="PIZZA"></param>
        /// <param name="SIZE"></param>
        /// <returns>Task of ApiResponse (APizza)</returns>
        public async System.Threading.Tasks.Task <ApiResponse <APizza> > ApiValuesPIZZASIZEGetAsyncWithHttpInfo(PIZZAS PIZZA, SIZES SIZE)
        {
            // verify the required parameter 'PIZZA' is set
            if (PIZZA == null)
            {
                throw new ApiException(400, "Missing required parameter 'PIZZA' when calling ValuesApi->ApiValuesPIZZASIZEGet");
            }
            // verify the required parameter 'SIZE' is set
            if (SIZE == null)
            {
                throw new ApiException(400, "Missing required parameter 'SIZE' when calling ValuesApi->ApiValuesPIZZASIZEGet");
            }

            var    localVarPath         = "/api/Values/{PIZZA}/{SIZE}";
            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
            }
            // 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("ApiValuesPIZZASIZEGet", 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>
        /// <returns>Task of APizza</returns>
        public async System.Threading.Tasks.Task <APizza> ApiValuesPIZZASIZEGetAsync(PIZZAS PIZZA, SIZES SIZE)
        {
            ApiResponse <APizza> localVarResponse = await ApiValuesPIZZASIZEGetAsyncWithHttpInfo(PIZZA, SIZE);

            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>
        /// <returns>APizza</returns>
        public APizza ApiValuesPIZZASIZEGet(PIZZAS PIZZA, SIZES SIZE)
        {
            ApiResponse <APizza> localVarResponse = ApiValuesPIZZASIZEGetWithHttpInfo(PIZZA, SIZE);

            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>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);
        }