private void SetMeatDishRating(Comment comment) { var sumMeatDishRatings = 0; double meatDishRating; Lunch lunch = db.Lunches.Find(comment.LunchId); var meatDishId = lunch.MeatDishId; int countMeatDishRatings = db.Comments.Where(c => c.Lunch.MeatDishId == meatDishId).Count(); if (countMeatDishRatings == 0) { meatDishRating = comment.MeatDishRating; } else { sumMeatDishRatings = db.Comments.Include(c => c.Lunch).Where(c => c.Lunch.MeatDishId == meatDishId).Sum(c => c.MeatDishRating); meatDishRating = (double)(sumMeatDishRatings + comment.MeatDishRating) / (countMeatDishRatings + 1); } MeatDish meatDish = db.MeatDishes.Find(meatDishId); meatDish.Rating = meatDishRating; db.Entry(meatDish).State = EntityState.Modified; }
public ActionResult Edit([Bind(Include = "MeatDishId,Name,Weight")] MeatDish meatDish) { if (ModelState.IsValid) { repository.Update(meatDish); repository.Save(); return(RedirectToAction("Index")); } return(View(meatDish)); }
static void Main(string[] args) { Chef chef = new Chef(); chef.PrintingTheValuesOfChef(); chef.ActiveChefs(); Console.WriteLine("................................"); Meat meat = new Meat(); meat.PrintMeatText(); meat.MeatRatio(); Console.WriteLine("................................"); MeatType meatType = new MeatType(); meatType.PrintMeatText(); meatType.ChooseMeatType(); meatType.DifferentMeatTypes(); Console.WriteLine("................................"); Meat[] printingMeatMessages = { new Meat(), new MeatDish(), new MeatType() }; printingMeatMessages[0].PrintMeatText(); printingMeatMessages[1].PrintMeatText(); printingMeatMessages[2].PrintMeatText(); Console.WriteLine("................................"); MeatVariations printingMeatText = new MeatVariations(); printingMeatText.PrintMeatText(); Console.WriteLine("................................"); Meat printingMeatText1 = new MeatDish(); printingMeatText1.PrintMeatText(); Console.WriteLine("................................"); // Console.ReadLine(); }
static void FarmDecorator() { //Step 1: Define some dishes, and how many of each we can make FreshSaladDish caesarSalad = new FreshSaladDish("Crisp romaine lettuce", "Freshly-grated Parmesan cheese", "House-made Caesar dressing"); caesarSalad.Display(); PastaDish fettuccineAlfredo = new PastaDish("Fresh-made daily pasta", "Creamy garlic alfredo sauce"); fettuccineAlfredo.Display(); MeatDish MeatLoverPizza = new MeatDish(true, "Pepperoni", "American"); MeatLoverPizza.Display(); Console.WriteLine("\nMaking these dishes available."); //Step 2: Decorate the dishes; now if we attempt to order them once we're out of ingredients, we can notify the customer Available fettuciniAvailable = new Available(fettuccineAlfredo, 3); Available caeserAvailable = new Available(caesarSalad, 4); Available meatAvailable = new Available(MeatLoverPizza, 3); fettuciniAvailable = new Available(fettuccineAlfredo, 2); //Step 3: Order a bunch of dishes fettuciniAvailable.OrderItem("John"); fettuciniAvailable.OrderItem("Sally"); fettuciniAvailable.OrderItem("Manush"); //fettuciniAvailable.OrderItem("Sally"); //fettuciniAvailable.OrderItem("Lisa"); //fettuciniAvailable.OrderItem("Hope"); //meatAvailable.OrderItem("John"); //meatAvailable.OrderItem("Bob"); //meatAvailable.OrderItem("Larry"); //meatAvailable.OrderItem("Trevor"); caeserAvailable.Display(); fettuciniAvailable.Display(); meatAvailable.Display(); }
static void Main(string[] args) { Chef chef = new Chef(); Chef chef1 = new Chef(2); Chef chef2 = new Chef(4, 1); int cheftype = chef.HowManyChefs; // not able to have parameters Console.WriteLine(cheftype); Meat meat = new Meat(2, 10); MeatVariations meat1 = new MeatVariations(); double meatPercentage = meat.MeatRatio(); double meatPercentage1 = meat1.GetanimalFlesh(); Console.WriteLine("the lean meat percentage is " + meatPercentage + " %"); Console.WriteLine("the lean meat percentage is " + meatPercentage1 + " %"); Console.WriteLine(""); Meat[] printingMeatMessages = { new Meat(), new MeatDish(), new MeatType() }; printingMeatMessages[0].PrintMeatText(); printingMeatMessages[1].PrintMeatText(); printingMeatMessages[2].PrintMeatText(); Console.WriteLine(""); MeatVariations printingMeatText = new MeatVariations(); printingMeatText.PrintMeatText(); Console.WriteLine(""); Meat printingMeatText1 = new MeatDish(); printingMeatText1.PrintMeatText(); }
static void Main(string[] args) { Cooking hemat = new Cooking(); MeatDish Korma = new MeatDish(); FryingVegDish ratatouille = new FryingVegDish(); }