public JObject DianZan() { JObject rv = new JObject(); int id = Convert.ToInt32(Request.Form["id"]); CookBook target = db.CookBooks.Find(id); if (target != null) { if (target.LikeNum == null) { target.LikeNum = 1; } else { target.LikeNum += 1; } rv["flag"] = true; rv["msg"] = "操作成功!"; } else { rv["flag"] = false; rv["msg"] = "操作失败!"; } db.SaveChanges(); return(rv); }
public void Awake() { if (instance != null) { Destroy(this); } instance = this; ingredientInventory = new List <Item>(); dessertInventory = new List <Item>(); otherInventory = new List <Item>(); myCookBook = new CookBook(); List <Item> recipe = new List <Item>(); Debug.Log("待解決bug:"); AddItem(new Item { itemName = Item.ItemName.糖, quantity = 0 }); AddItem(new Item { itemName = Item.ItemName.雞蛋, quantity = 0 }); AddItem(new Item { itemName = Item.ItemName.布丁, quantity = 0 }); myCookBook.GetCookBook().Add( Item.ItemName.布丁, new Recipe( new Item { itemName = Item.ItemName.雞蛋, quantity = 1 }, new Item { itemName = Item.ItemName.糖, quantity = 1 }, recipe) ); }
void OnCollisionEnter(Collision other) { // Only allows ingredients to go into stove if (canCook && other.gameObject.CompareTag("ingredient") && !other.gameObject.GetComponent <Pickup>().isMeal) { ingredients.Add(other.gameObject.GetComponent <Pickup>()); DisplayIngredient(other.gameObject.GetComponent <Pickup>().GrabPickup()); Pickup meal = CookBook.GetRecipe(ingredients); if (meal != null) { ingredients.RemoveRange(0, ingredients.Count); canCook = false; StartCoroutine(CookingCoroutine(meal)); ClearDisplay(); } } // Conditional statement for Mr. Clean removing ingredients in a stove else if (other.gameObject.GetComponent <Pickup>() && other.gameObject.GetComponent <Pickup>().prefabName == "Clean") { ingredients.RemoveRange(0, ingredients.Count); ClearDisplay(); Destroy(other.gameObject); } }
public ActionResult CreateCookBook(CreateCookBookModel model) { CookBook cookBook = new CookBook(); cookBook.Title = model.Title; cookBook.SubTitle = model.SubTitle; cookBook.Content = model.Content; cookBook.Image = model.Image; db.CookBooks.Add(cookBook); db.SaveChanges(); foreach (var step in model.Steps) { CookBookStep cookBookStep = new CookBookStep(); cookBookStep.OrderID = model.Steps.IndexOf(step); cookBookStep.ImageUrl = step.ImageUrl; cookBookStep.Content = step.Content; cookBookStep.CookBookID = cookBook.ID; cookBookStep.CookBook = cookBook; db.CookBookSteps.Add(cookBookStep); } db.SaveChanges(); return(RedirectToAction("Index")); }
public JObject AddToCart() { JObject rv = new JObject(); int id = Convert.ToInt32(Request.Form["id"]); string account = Convert.ToString(Session["UserAccount"]); CookBook target = db.CookBooks.Find(id); User user = db.Users.Where(a => a.Account == account).FirstOrDefault(); if (target != null && string.IsNullOrEmpty(account)) { user.CookBookShopCarted.Add(target); rv["flag"] = true; rv["msg"] = "操作成功!"; } else { rv["flag"] = false; rv["msg"] = "操作失败!"; } db.SaveChanges(); return(rv); }
public ActionResult DeleteConfirmed(int id) { CookBook cookBook = db.CookBooks.Find(id); db.CookBooks.Remove(cookBook); db.SaveChanges(); return(RedirectToAction("Index")); }
public CookBooksEditViewModel(CookBook cookBook) { CookBookId = cookBook.CookBookId; CookBookName = cookBook.CookBookName; CookBookDescription = cookBook.CookBookDescription; Recipes = cookBook.Recipes; OwnerId = cookBook.OwnerId; IsDeletable = cookBook.IsDeletable; }
/// <summary> /// Default is formed from: input.RecipeId.ToString("00000") /// </summary> public string GetDefaultFileName(CookBook input) { string fileName = input.RecipeId.ToString("00000"); fileName = IllegalInFileName.Replace(fileName, "_"); fileName += ".sql"; return(fileName); }
public ActionResult Edit([Bind(Include = "ID,CreateDate,Title,SubTitle,Image,Content,NeedPayment,LikeNum")] CookBook cookBook) { if (ModelState.IsValid) { db.Entry(cookBook).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(cookBook)); }
public async Task <ActionResult> Delete(int id) { CookBook cookBook = await repository.GetAsync(id); if (cookBook == null) { return(HttpNotFound()); } return(View(cookBook)); }
public static CookBook ConvertToACE(this Seg4_CraftTable.Precursor input) { var result = new CookBook(); result.RecipeId = input.RecipeID; result.TargetWCID = input.Target; result.SourceWCID = input.Source; return result; }
public async Task <ICookBook> LoadCookBookFromFolder(string path, CancellationToken token) { if (!Directory.Exists(path)) { throw new IOException("Invalid path (Directory not found)"); } Mediamanger mm = new Mediamanger(path, token); return(await CookBook.Load(mm, token)); }
public ActionResult Create([Bind(Include = "ID,CreateDate,Title,SubTitle,Image,Content,NeedPayment,LikeNum")] CookBook cookBook) { if (ModelState.IsValid) { db.CookBooks.Add(cookBook); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(cookBook)); }
public Main() { InitializeComponent(); BOOK = CookBook.GetFromJson(); if (BOOK == null) { BOOK = new CookBook(); } SetItemsInTree(); }
private void WriteData(Receipe[] myList) { XmlSerializer ser = new XmlSerializer(typeof(CookBook)); StreamWriter myWriter = new StreamWriter("./Data/Receipes.xml"); CookBook toPersist = new CookBook { Receipes = myList }; ser.Serialize(myWriter, toPersist); myWriter.Close(); }
public async Task <ICookBook> LoadCookBookFromFileStream(Stream File, CancellationToken token) { if (File == null) { throw new IOException("Invalid path (Directory not found)"); } var archive = new System.IO.Compression.ZipArchive(File); Mediamanger mm = new Mediamanger(archive, token); return(await CookBook.Load(mm, token)); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, CookBook CookBook) { app.UseCors(builder => builder.AllowAnyOrigin() .AllowAnyHeader() .AllowAnyMethod()); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseMvc(); DbIntitializer.Initialize(CookBook); }
public ActionResult PublicRecipes() { string userIdValue = new CurrentUserIdRetriever() .GetUserId(User.Identity as ClaimsIdentity); CookBook cookBook = new CookBook(); cookBook.Recipes = new EntitySorter() .SortRecipesAndReturn(repository.GetAll() .Where(x => x.IsPublic == true && x.OwnerId != userIdValue) .ToList()) .ToList(); return(View(cookBook)); }
public Recipe readOne(string name) { CookBook newCB = new CookBook(); List <Recipe> allRecipies = newCB.readAll(); foreach (Recipe oneRecipe in allRecipies) { if (oneRecipe.recipeName == name) { return(oneRecipe); } } return(newCB.defaultRecipe); }
// GET: MngCookBook/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CookBook cookBook = db.CookBooks.Find(id); if (cookBook == null) { return(HttpNotFound()); } return(View(cookBook)); }
/// <summary> /// Converts a GDLE precursor to ACE cookbook /// </summary> public static bool TryConvert(Models.RecipePrecursor input, out CookBook result) { try { result = new CookBook(); result.RecipeId = input.RecipeId ?? 0; result.SourceWCID = input.Tool; result.TargetWCID = input.Target; return(true); } catch { result = null; return(false); } }
/// <summary> /// Converts ACE cookbook to GDLE precursor /// </summary> public static bool TryConvert(CookBook input, out Models.RecipePrecursor result) { try { result = new Models.RecipePrecursor(); result.RecipeId = input.RecipeId; result.Tool = input.SourceWCID; result.Target = input.TargetWCID; return(true); } catch { result = null; return(false); } }
static void Main(string[] args) { CookBook book = new CookBook() { Title = "Simona's CookBook", Author = "Simona" }; fillBook(book); PrintRecipes(book.Recipes); //print all the easy recipes PrintRecipes(book.Recipes.Filter(r => r.Difficulty == Difficulty.Easy)); //print all the pasta recipes Recipes pastarecipes = book.Recipes.Filter(r => r.Ingredients.Filter(i => i.Name.ToLower().Contains("pasta")).Count > 0); PrintRecipes(pastarecipes); Console.ReadLine(); }
/// <summary> /// 发表评论 /// </summary> /// <returns></returns> public JObject CreateComment() { JObject rv = new JObject(); string account = Request.Form["account"]; string content = Request.Form["content"]; string cookbookid = Request.Form["cookbookid"]; User createUser = db.Users.Where(a => a.Account == account).FirstOrDefault(); CookBook cookBook = db.CookBooks.Find(Convert.ToInt32(cookbookid)); CookBookComment comment = new CookBookComment(); comment.CreateDate = DateTime.Now; comment.Content = content; comment.CreateUser = createUser; comment.CreateUserID = createUser.ID; comment.CookBook = cookBook; comment.CookBookID = cookBook.ID; db.CookBookComments.Add(comment); try { db.SaveChanges(); rv["flag"] = true; rv["msg"] = "发表成功!"; } catch { rv["flag"] = false; rv["msg"] = "发表评论发生了错误"; } return(rv); }
static void fillBook(CookBook book) { Ingredient fusilli = new Ingredient() { Name = "pasta fusilli", Quantity = "250 gr" }; Ingredient tagliatelle = new Ingredient() { Name = "pasta tagliatelle", Quantity = "250 gr" }; Ingredient eggs = new Ingredient() { Name = "eggs", Quantity = "3" }; Ingredient parmesan = new Ingredient() { Name = "parmesan", Quantity = "50 gr" }; Ingredient speck = new Ingredient() { Name = "speck", Quantity = "100 gr" }; Ingredient mushrooms = new Ingredient() { Name = "mushrooms", Quantity = "250 gr" }; Ingredient pumpkin = new Ingredient() { Name = "pumpkin", Quantity = "250 gr" }; Ingredient chicken = new Ingredient() { Name = "chicken", Quantity = "200 gr" }; Ingredient tomatoes = new Ingredient() { Name = "tomatoes", Quantity = "250 gr" }; Recipe carbonara = new Recipe() { Title = "Pasta Carbonara", Description = "Easypeasy", Difficulty = Difficulty.Easy, Duration = 10 }; carbonara.Ingredients.Add(fusilli); carbonara.Ingredients.Add(eggs); carbonara.Ingredients.Add(parmesan); carbonara.Ingredients.Add(speck); Recipe pollofunghi = new Recipe() { Title = "Chicken with Mushrooms", Duration = 50, Difficulty = Difficulty.Advanced }; pollofunghi.Ingredients.Add(chicken); pollofunghi.Ingredients.Add(mushrooms); Recipe pastazuccafunghi = new Recipe() { Title = "Pasta with pumpkin and mushrooms", Duration = 30, Difficulty = Difficulty.Medium }; pastazuccafunghi.Ingredients.Add(tagliatelle); pastazuccafunghi.Ingredients.Add(pumpkin); pastazuccafunghi.Ingredients.Add(mushrooms); pastazuccafunghi.Ingredients.Add(parmesan); Recipe amatriciana = new Recipe() { Title = "Pasta Amatriciana", Description = "Easypeasy", Difficulty = Difficulty.Easy, Duration = 10 }; amatriciana.Ingredients.Add(fusilli); amatriciana.Ingredients.Add(tomatoes); amatriciana.Ingredients.Add(speck); book.Recipes.Add(carbonara); book.Recipes.Add(pollofunghi); book.Recipes.Add(pastazuccafunghi); book.Recipes.Add(amatriciana); }
public void AddRecord(List <string> fields) { if (CurrentTable == Table.Recipe) { Recipe = new Recipe(); PopulateFields(Recipe, fields); } else if (CurrentTable == Table.RecipeRequirementsBool) { var record = new RecipeRequirementsBool(); PopulateFields(record, fields); Recipe.RecipeRequirementsBool.Add(record); } else if (CurrentTable == Table.RecipeRequirementsDID) { var record = new RecipeRequirementsDID(); PopulateFields(record, fields); Recipe.RecipeRequirementsDID.Add(record); } else if (CurrentTable == Table.RecipeRequirementsFloat) { var record = new RecipeRequirementsFloat(); PopulateFields(record, fields); Recipe.RecipeRequirementsFloat.Add(record); } else if (CurrentTable == Table.RecipeRequirementsIID) { var record = new RecipeRequirementsIID(); PopulateFields(record, fields); Recipe.RecipeRequirementsIID.Add(record); } else if (CurrentTable == Table.RecipeRequirementsInt) { var record = new RecipeRequirementsInt(); PopulateFields(record, fields); Recipe.RecipeRequirementsInt.Add(record); } else if (CurrentTable == Table.RecipeRequirementsString) { var record = new RecipeRequirementsString(); PopulateFields(record, fields); Recipe.RecipeRequirementsString.Add(record); } else if (CurrentTable == Table.RecipeMod) { CurrentRecipeMod = new RecipeMod(); PopulateFields(CurrentRecipeMod, fields); Recipe.RecipeMod.Add(CurrentRecipeMod); } else if (CurrentTable == Table.RecipeModsBool) { var record = new RecipeModsBool(); PopulateFields(record, fields); CurrentRecipeMod.RecipeModsBool.Add(record); } else if (CurrentTable == Table.RecipeModsDID) { var record = new RecipeModsDID(); PopulateFields(record, fields); CurrentRecipeMod.RecipeModsDID.Add(record); } else if (CurrentTable == Table.RecipeModsFloat) { var record = new RecipeModsFloat(); PopulateFields(record, fields); CurrentRecipeMod.RecipeModsFloat.Add(record); } else if (CurrentTable == Table.RecipeModsIID) { var record = new RecipeModsIID(); PopulateFields(record, fields); CurrentRecipeMod.RecipeModsIID.Add(record); } else if (CurrentTable == Table.RecipeModsInt) { var record = new RecipeModsInt(); PopulateFields(record, fields); CurrentRecipeMod.RecipeModsInt.Add(record); } else if (CurrentTable == Table.RecipeModsString) { var record = new RecipeModsString(); PopulateFields(record, fields); CurrentRecipeMod.RecipeModsString.Add(record); } else if (CurrentTable == Table.Cookbook) { var record = new CookBook(); PopulateFields(record, fields); Cookbooks.Add(record); record.Recipe = Recipe; } }
public MealController(CookBook context) { this.context = context; }
public void AttachCookBookAndAddRecipe(CookBook cookBook, Recipe recipe) { context.Entry(cookBook).State = EntityState.Modified; DbSet.Add(recipe); }
public void AttachCookBook(CookBook cookBook) { context.Entry(cookBook).State = EntityState.Modified; }
public IngredientController(CookBook context) { this.context = context; }