private void Populate(IngredientsModel model) { iconView.ClearAdapter(); IconViewAdapter <IngredientsModelBase> adapter = new IconViewAdapter <IngredientsModelBase>(model, null); iconView.Adapter = adapter; }
public IHttpActionResult AddRecipes(Request r) { if (string.IsNullOrEmpty(r.Rm.Id)) { if (r.Im.Any()) { var recipeId = Guid.NewGuid().ToString(); foreach (var ingredient in r.Im) { if (!string.IsNullOrEmpty(ingredient.Amount) && !string.IsNullOrEmpty(ingredient.Calories) && !string.IsNullOrEmpty(ingredient.Name)) { ingredient.Id = Guid.NewGuid().ToString(); ingredient.RecipesId = recipeId; _db.Ingredients.Add(ingredient); } else { return(BadRequest("Please fill out all fields")); } } _db.Recipes.Add(new RecipesModel { Description = r.Rm.Description, Id = recipeId, UserId = UserViewModel.GetCurrentUser().Id }); _db.SaveChanges(); return(Ok(recipeId)); } return(BadRequest("No ingredients")); } var recipes = _db.Recipes.Find(r.Rm.Id); if (recipes != null && UserViewModel.GetCurrentUser().Id == recipes.UserId) { var findIngredient = new IngredientsModel(); foreach (var i in r.Im) { findIngredient = _db.Ingredients.Find(i.Id); if (findIngredient != null) { findIngredient.Amount = i.Amount; findIngredient.Calories = i.Calories; findIngredient.FoodId = i.FoodId; findIngredient.Name = i.Name; } else { _db.Ingredients.Add(i); } } recipes.Description = r.Rm.Description; _db.Entry(findIngredient).State = EntityState.Modified; _db.SaveChanges(); return(Ok(r.Rm.Id)); } return(BadRequest()); }
public ActionResult Ingredients(IngredientsModel smodel) { smodel.generalPrice += NewPrice(smodel); smodel.generalOrder += NewOrder(smodel); TempData["price"] = (smodel.generalPrice).ToString(); TempData["order"] = smodel.generalOrder; return(RedirectToAction("Address", "Address")); }
public async Task <ActionResult> DeleteConfirmed(int id) { IngredientsModel ingredientsModel = await db.Ingredients.FindAsync(id); db.Ingredients.Remove(ingredientsModel); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
// GET: Ingredients public ActionResult Ingredients() { IngredientsModel smodel = new IngredientsModel(); smodel.generalPrice = int.Parse(TempData["price"].ToString()); smodel.generalOrder = TempData["order"].ToString(); smodel.QuantityList = FillQuantity(); return(View(smodel)); }
public async Task <ActionResult <int> > Put(int id, [FromBody] IngredientsModel ingredientsModel) { if (id != ingredientsModel.Id) { return(BadRequest()); } return(await _ingredientsService.Update(ingredientsModel)); }
public async Task <ActionResult> Edit([Bind(Include = "Id,Name,Ammount,Prep,RecipeModelsId")] IngredientsModel ingredientsModel) { if (ModelState.IsValid) { db.Entry(ingredientsModel).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(ingredientsModel)); }
public async Task <ActionResult> Create([Bind(Include = "Id,Name,Ammount,Prep,RecipeModelsId")] IngredientsModel ingredientsModel) { if (ModelState.IsValid) { db.Ingredients.Add(ingredientsModel); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(ingredientsModel)); }
// GET: IngredientsModels/Delete/5 public async Task <ActionResult> Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } IngredientsModel ingredientsModel = await db.Ingredients.FindAsync(id); if (ingredientsModel == null) { return(HttpNotFound()); } return(View(ingredientsModel)); }
public CheckList() { allModel = new IngredientsModel(); int position = 0; foreach (IngredientModel ingredientModel in allModel.Children) { CheckBoxWithId newBox = new CheckBoxWithId(ingredientModel.Id, position) { Content = ingredientModel.Description }; newBox.Width = 255; newBox.Click += NewBox_Click; boxes.Add(newBox.Id, newBox); ComboBoxWithId portions = new ComboBoxWithId(newBox.Id, position); portions.Text = ingredientModel.Portions.ToString(); portions.FontWeight = FontWeights.Bold; portions.Visibility = Visibility.Hidden; portions.Items.Add(new TextBlock() { Text = "1" }); portions.Items.Add(new TextBlock() { Text = "2" }); portions.Items.Add(new TextBlock() { Text = "3" }); portions.SelectedIndex = 0; portions.SelectionChanged += Portions_SelectionChanged; this.portions.Add(portions); StackPanel panel = new StackPanel(); panel.Orientation = Orientation.Horizontal; panel.Children.Add(newBox); panel.Children.Add(portions); this.AddChild(panel); ++position; } }
public async Task <IngredientsModel> InsertIngredientsIntoTable(IngredientsModel model) { var table = await _tableStorage.GetTableReference(_ingredientsTable); model.IdIngredient = Guid.NewGuid().ToString(); var entity = new IngredientEntity() { PartitionKey = model.IdIngredient, RowKey = new Guid().ToString(), IngredientsModelData = model }; var tableOperation = TableOperation.InsertOrMerge(entity); await table.ExecuteAsync(tableOperation); return(model); }
public void CheckItems(int id, int parentType) { IngredientsModel selectionModel = new IngredientsModel(id, parentType); ClearItems(); foreach (IngredientModel ingredientModel in selectionModel.Children) { model.Children.Add(allModel.Children.Where(m => m.Id == ingredientModel.Id).Single()); stopPortions = true; boxes[ingredientModel.Id].IsChecked = true; portions[boxes[ingredientModel.Id].Position].SelectedIndex = ingredientModel.Portions - 1; portions[boxes[ingredientModel.Id].Position].Visibility = Visibility.Visible; stopPortions = false; } }
public IActionResult Index() { UserEntity user = GetLoggedUser(_repository.User); IngredientsModel ingredients = GetOrCreateIngridientsSettings(user); MealSettingsModel mealSettings = GetOrCreateUserMealSettings(user); var indicators = _repository.Indicator.GetLastIndicatorFromTable(user.Id).Result; var model = new Settings() { PersonalData = new PersonalDataSettings { Name = user.Name, Lastname = user.Lastname, Height = indicators != null? indicators.IndicatorsModelData.Height: null, Weight = indicators != null ? indicators.IndicatorsModelData.Weight : null, Age = user.Age, Gender = user.Gender }, Menu = new MenuSettings { Preferences = mealSettings.Preferences, DietAim = mealSettings.DietAim }, Ingridients = new IngridientsSettings { Chocolate = ingredients.Chocolate, Eggs = ingredients.Eggs, Milk = ingredients.Milk, Peanuts = ingredients.Peanuts, Potatoes = ingredients.Potatoes, Soy = ingredients.Soy, Tomatoes = ingredients.Tomatoes, Wheat = ingredients.Wheat }, Activity = new ActivitySettings { LifeStyle = user.LifeStyle } }; return(View(model)); }
public int NewPrice(IngredientsModel smodel) { int newPrice = 0; if (smodel.pepperoni == true) { switch (smodel.pepperoniQuantity) { case "0": newPrice += 400; break; case "1": newPrice += 450; break; case "2": newPrice += 800; break; } } if (smodel.ham == true) { switch (smodel.hamQuantity) { case "0": newPrice += 400; break; case "1": newPrice += 450; break; case "2": newPrice += 800; break; } } if (smodel.groundBeef == true) { switch (smodel.groundBeefQuantity) { case "0": newPrice += 400; break; case "1": newPrice += 450; break; case "2": newPrice += 800; break; } } if (smodel.salami == true) { switch (smodel.salamiQuantity) { case "0": newPrice += 400; break; case "1": newPrice += 450; break; case "2": newPrice += 800; break; } } if (smodel.bacon == true) { switch (smodel.baconQuantity) { case "0": newPrice += 400; break; case "1": newPrice += 450; break; case "2": newPrice += 800; break; } } if (smodel.redPeppers == true) { switch (smodel.redPeppersQuantity) { case "0": newPrice += 400; break; case "1": newPrice += 450; break; case "2": newPrice += 800; break; } } if (smodel.pineapple == true) { switch (smodel.pineappleQuantity) { case "0": newPrice += 400; break; case "1": newPrice += 450; break; case "2": newPrice += 800; break; } } if (smodel.purpleOnion == true) { switch (smodel.purpleOnionQuantity) { case "0": newPrice += 400; break; case "1": newPrice += 450; break; case "2": newPrice += 800; break; } } return(newPrice); }
public string NewOrder(IngredientsModel smodel) { string newOrder = ""; if (smodel.pepperoni == true) { switch (smodel.pepperoniQuantity) { case "0": newOrder += ", poco pepperoni"; break; case "1": newOrder += ", pepperoni medio"; break; case "2": newOrder += ", mucho pepperoni"; break; } } if (smodel.ham == true) { switch (smodel.hamQuantity) { case "0": newOrder += ", poco jamón"; break; case "1": newOrder += ", jamón medio"; break; case "2": newOrder += ", mucho jamón"; break; } } if (smodel.groundBeef == true) { switch (smodel.groundBeefQuantity) { case "0": newOrder += ", poca carne molida"; break; case "1": newOrder += ", carne molida media"; break; case "2": newOrder += ", mucha carne molida"; break; } } if (smodel.salami == true) { switch (smodel.salamiQuantity) { case "0": newOrder += ", poco salami"; break; case "1": newOrder += ", salami medio"; break; case "2": newOrder += ", mucho salami"; break; } } if (smodel.bacon == true) { switch (smodel.baconQuantity) { case "0": newOrder += ", poco tocino"; break; case "1": newOrder += ", tocino medio"; break; case "2": newOrder += ", mucho tocino"; break; } } if (smodel.redPeppers == true) { switch (smodel.redPeppersQuantity) { case "0": newOrder += ", poco chile dulce"; break; case "1": newOrder += ", chile dulce medio"; break; case "2": newOrder += ", mucho chile dulce"; break; } } if (smodel.pineapple == true) { switch (smodel.pineappleQuantity) { case "0": newOrder += ", poca piña"; break; case "1": newOrder += ", piña media"; break; case "2": newOrder += ", mucha piña"; break; } } if (smodel.purpleOnion == true) { switch (smodel.purpleOnionQuantity) { case "0": newOrder += ", poca cebolla"; break; case "1": newOrder += ", cebolla media"; break; case "2": newOrder += ", mucha cebolla"; break; } } return(newOrder); }
public async Task <ActionResult <IngredientsModel> > Post(IngredientsModel ingredientsModel) { await _ingredientsService.Save(ingredientsModel); return(CreatedAtAction("Get", new { id = ingredientsModel.Id }, ingredientsModel)); }
public async Task <int> Update(IngredientsModel ingredients) { var ingredientsEntity = _mapper.Map <Ingredients>(ingredients); return(await _ingredientsRepository.Update(ingredientsEntity)); }