public CustomPizza(ACrust crust, ASize size, List <ATopping> topping) { Name = "Custom Pizza"; Crust = crust; Size = size; Toppings = topping; }
/// <summary> /// Map DBPizza => APizza /// Uses enum to determine which crust class to return. /// Note: premade pizza classes have constructors to set all variables properly. /// Therefore, they do not need any data tobe passed innto them. /// Custom pizza however only has 1 constructor that requires crust, size, and toppings /// to be passed into them. /// </summary> /// <param name="entity"></param> /// <returns></returns> public APizza Map(DBPizza entity) { APizza pizza; switch (entity.PIZZA) { case PIZZAS.CUSTOM: ACrust crust = mapperCrust.Map(entity.DBCrust); ASize size = mapperSize.Map(entity.DBSize); List <ATopping> toppings = new List <ATopping>(); entity.DBPlacedToppings.ToList().ForEach(placedTopping => toppings.Add(mapperTopping.Map(placedTopping.Topping))); pizza = new CustomPizza(crust, size, toppings); break; case PIZZAS.HAWAIIAN: pizza = new HawaiianPizza(mapperSize.Map(entity.DBSize)); break; case PIZZAS.MEAT: pizza = new MeatPizza(mapperSize.Map(entity.DBSize)); break; case PIZZAS.VEGAN: pizza = new VeganPizza(mapperSize.Map(entity.DBSize)); break; default: throw new ArgumentException("Pizza not recognized. Pizza could not be mapped properly"); } pizza.CalculatePrice(); pizza.ID = entity.ID; return(pizza); }
/// <summary> /// /// </summary> /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="body"> (optional)</param> /// <returns>ApiResponse of Object(void)</returns> public ApiResponse <Object> ApiSizePostWithHttpInfo(ASize body = null) { var localVarPath = "/api/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[] { "application/json-patch+json", "application/json", "text/json", "application/_*+json" }; String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); // to determine the Accept header String[] localVarHttpHeaderAccepts = new String[] { }; String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); if (localVarHttpHeaderAccept != null) { localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); } if (body != null && body.GetType() != typeof(byte[])) { localVarPostBody = this.Configuration.ApiClient.Serialize(body); // http body (model) parameter } else { localVarPostBody = body; // byte array } // make the HTTP request IRestResponse localVarResponse = (IRestResponse)this.Configuration.ApiClient.CallApi(localVarPath, Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarPathParams, localVarHttpContentType); int localVarStatusCode = (int)localVarResponse.StatusCode; if (ExceptionFactory != null) { Exception exception = ExceptionFactory("ApiSizePost", localVarResponse); if (exception != null) { throw exception; } } return(new ApiResponse <Object>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => string.Join(",", x.Value)), null)); }
public Asteroid(PointF pos, ASize size, float dir) : base(pos) { RotationIncrement = RNG.NextDoubleRange(-3, 3); DeltaX = RNG.NextDoubleRange(-6, 6); DeltaY = RNG.NextDoubleRange(-6, 6); Acceleration = RNG.NextDoubleRange(0.1f, 3.0f); Model = GenerateAsteroid(50, RNG.Next(6, 14), 0.7f, size); Active = false; CurrentSafeTime = SafeTimer; AsteroidSize = size; Direction = dir; }
public IActionResult PlaceOrderWithMeat() { var sessionOrder = Utils.GetCurrentOrder(HttpContext.Session); APizza pizza = new APizza(); pizza.Pizza = PIZZAS.MEAT; ASize size = new ASize(); size.Size = SIZES.LARGE; pizza.Size = size; sessionOrder.Pizza.Add(pizza); bool result = FEOrderClient.AddOrder(sessionOrder); return(RedirectToAction("Index", "Home")); }
public IActionResult Post([FromBody] ASize size) { if (size == null) { return(BadRequest("The size you are trying to add is empty")); } else { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } else { repository.Add(size); return(CreatedAtAction(nameof(Get), new { id = size.ID }, size)); } } }
public IActionResult Put(int id, [FromBody] ASize size) { if (size == null) { return(NoContent()); } else { if (!ModelState.IsValid) { return(NoContent()); } else { size.ID = id; repository.Update(size); return(CreatedAtAction(nameof(Get), new { id = size.ID }, size)); } } }
public VeganPizza(ASize size) { Name = "Vegan (Abomination) Pizza"; PIZZA = PIZZAS.VEGAN; AddSize(size); }
/// <summary> /// Map DBPizza => DBPizza /// Sets enum bassed off what pizza class was passed into it. /// </summary> /// <param name="model"></param> /// <returns></returns> public DBPizza Map(APizza model, PizzaDbContext context, bool update = false) { int tempID = model.ID; ASize tempSize = model.Size; switch (model.PIZZA)//if model is a preset pizza, throw everything away and set it to the preset { case PIZZAS.HAWAIIAN: model = new HawaiianPizza(tempSize); break; case PIZZAS.MEAT: model = new MeatPizza(tempSize); break; case PIZZAS.VEGAN: model = new VeganPizza(tempSize); break; case PIZZAS.CUSTOM: break; default: throw new ArgumentException("Pizza not recognized. Pizza could not be mapped properly"); } model.Size = tempSize; model.ID = tempID;//ensure id wasnt lost in the switch case DBPizza dbPizza = context.DBPizzas .Include(pizza => pizza.DBCrust) .Include(pizza => pizza.DBSize) .Include(pizza => pizza.DBPlacedToppings) .ThenInclude(placedTopping => placedTopping.Topping) .FirstOrDefault(pizza => pizza.ID == model.ID) ?? new DBPizza(); if (dbPizza.ID != 0 && !update) { return(dbPizza); } dbPizza.PIZZA = model.PIZZA; dbPizza.DBCrust = mapperCrust.Map(model.Crust, context, update); dbPizza.DBSize = mapperSize.Map(model.Size, context, update); List <DBTopping> mappedToppings = new List <DBTopping>(); model.Toppings.ForEach(topping => mappedToppings.Add(mapperTopping.Map(topping, context, update))); dbPizza.DBPlacedToppings.Clear(); foreach (var group in mappedToppings.GroupBy(topping => topping.TOPPING)) { var firstTopping = group.Last(); if (firstTopping is null) { throw new ArgumentException("Something went wrong!"); } DBPlacedTopping placedTopping = context.DBPlacedToppings .Include(placedTopping => placedTopping.Pizza).Include(placedTopping => placedTopping.Topping) .FirstOrDefault(placedTopping => placedTopping.Pizza.ID == dbPizza.ID && placedTopping.Topping.ID == firstTopping.ID) ?? new DBPlacedTopping(); if (placedTopping.ID != 0 && !update) { continue; } placedTopping.Pizza = dbPizza; placedTopping.Topping = firstTopping; dbPizza.DBPlacedToppings.Add(placedTopping); } model.CalculatePrice(); dbPizza.Price = model.Price; if (dbPizza.ID == 0) { context.DBPizzas.Add(dbPizza); } return(dbPizza); }
/// <summary> /// /// </summary> /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="id"></param> /// <param name="body"> (optional)</param> /// <returns>Task of void</returns> public async System.Threading.Tasks.Task ApiSizeIdPutAsync(int?id, ASize body = null) { await ApiSizeIdPutAsyncWithHttpInfo(id, body); }
public HawaiianPizza(ASize size) { Name = "Hawaiian Pizza"; PIZZA = PIZZAS.HAWAIIAN; AddSize(size); }
public void Test_SizeName(ASize Size) { Assert.NotNull(Size.Name); Assert.Equal(Size.Name, Size.ToString()); }
/// <summary> /// /// </summary> /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="id"></param> /// <param name="body"> (optional)</param> /// <returns></returns> public void ApiSizeIdPut(int?id, ASize body = null) { ApiSizeIdPutWithHttpInfo(id, body); }
/// <summary> /// Generates an irregularly shaped polygon based on the radius, vertices, variance and size being passed in. /// </summary> /// <param name="radius"></param> /// <param name="vertices"></param> /// <param name="variance"></param> /// <param name="size"></param> /// <returns></returns> public static GraphicsPath GenerateAsteroid(int radius, int vertices, float variance, ASize size) { List <PointF> points = new List <PointF>(); GraphicsPath gp = new GraphicsPath(); Matrix m = new Matrix(); double angle = 0; for (int i = 0; i < vertices; i++, angle = (2 * Math.PI / vertices) * i) { points.Add(new PointF((float)(Math.Cos(angle) * (radius - (RNG.NextDouble() * radius * variance))), (float)(Math.Sin(angle) * (radius - (RNG.NextDouble() * radius * variance))))); } gp.AddPolygon(points.ToArray()); switch (size) { case ASize.Large: m.Scale(1.5f, 1.5f); break; case ASize.Medium: m.Scale(1.0f, 1.0f); break; case ASize.Small: m.Scale(0.4f, 0.4f); break; } gp.Transform(m); return(gp); }
public MeatPizza(ASize size) { Name = "Meat Pizza"; PIZZA = PIZZAS.MEAT; AddSize(size); }
public void Put(int id, [FromBody] ASize value) { value.ID = id; repo.Update(value); }
public void Post([FromBody] ASize value) { repo.Add(value); }
/// <summary> /// /// </summary> /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="id"></param> /// <param name="body"> (optional)</param> /// <returns>Task of ApiResponse</returns> public async System.Threading.Tasks.Task <ApiResponse <Object> > ApiSizeIdPutAsyncWithHttpInfo(int?id, ASize body = null) { // verify the required parameter 'id' is set if (id == null) { throw new ApiException(400, "Missing required parameter 'id' when calling SizeApi->ApiSizeIdPut"); } var localVarPath = "/api/Size/{id}"; 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[] { "application/json-patch+json", "application/json", "text/json", "application/_*+json" }; String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); // to determine the Accept header String[] localVarHttpHeaderAccepts = new String[] { }; String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); if (localVarHttpHeaderAccept != null) { localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); } if (id != null) { localVarPathParams.Add("id", this.Configuration.ApiClient.ParameterToString(id)); // path parameter } if (body != null && body.GetType() != typeof(byte[])) { localVarPostBody = this.Configuration.ApiClient.Serialize(body); // http body (model) parameter } else { localVarPostBody = body; // byte array } // make the HTTP request IRestResponse localVarResponse = (IRestResponse)await this.Configuration.ApiClient.CallApiAsync(localVarPath, Method.PUT, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarPathParams, localVarHttpContentType); int localVarStatusCode = (int)localVarResponse.StatusCode; if (ExceptionFactory != null) { Exception exception = ExceptionFactory("ApiSizeIdPut", localVarResponse); if (exception != null) { throw exception; } } return(new ApiResponse <Object>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => string.Join(",", x.Value)), null)); }
/// <summary> /// /// </summary> /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="body"> (optional)</param> /// <returns></returns> public void ApiSizePost(ASize body = null) { ApiSizePostWithHttpInfo(body); }
public override void AddSize(ASize size) { Size = size; }
/// <summary> /// /// </summary> /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="body"> (optional)</param> /// <returns>Task of void</returns> public async System.Threading.Tasks.Task ApiSizePostAsync(ASize body = null) { await ApiSizePostAsyncWithHttpInfo(body); }