public FoodPage( string mainText, FoodInfo[] food, string buttonText, string eatMainText, string postEatButtonText ) { this.mainText = mainText; this.food = food; this.buttonText = buttonText; this.eatMainText = eatMainText; this.postEatButtonText = postEatButtonText; }
/// <summary> /// add /// </summary> /// <param name="FoodInfo"></param> /// <returns></returns> public int Add(FoodInfo model) { var str = GetInsertStr(model) + " select @@identity"; var dict = GetParameters(model); return(Convert.ToInt32(SqlHelperHere.ExecuteScalar(str, dict))); }
public async Task <IActionResult> Edit(int id, [Bind("FoodID,FoodName,Description,Extension,Price,CompanyID,CategoryID")] FoodInfo foodInfo) { if (id != foodInfo.FoodID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(foodInfo); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FoodInfoExists(foodInfo.FoodID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CategoryID"] = new SelectList(_context.FoodCategories, "CategoryID", "CategoryName", foodInfo.CategoryID); ViewData["CompanyID"] = new SelectList(_context.Companies, "CompanyID", "CompanyName", foodInfo.CompanyID); return(View(foodInfo)); }
private FoodInfo CreateNewFood(string category, string food) { var pictureUrls = BingFacade.FindImages(String.Format("{0} - {1}", category, food)); var pictureId = 0; var pictures = new List <FoodPicture>(); foreach (var url in pictureUrls) { pictures.Add(new FoodPicture { Id = pictureId, Url = url, Relevance = 0, IsUserUploaded = false }); pictureId++; } var newFood = new FoodInfo { Category = category, Food = food, Pictures = pictures }; FoodRepo.Store(newFood); return(newFood); }
/// <summary> /// update /// </summary> /// <param name="FoodInfo"></param> /// <returns></returns> public void Update(FoodInfo model) { CacheHelper.LockCache("FoodInfo"); var str = GetUpdateStr(model); var dict = GetParameters(model); SqlHelperHere.ExcuteNon(str, dict); CacheHelper.ReleaseLock("FoodInfo"); }
public float GetProcessProgress(Item item) { foreach (ItemSlot itemSlot in this.m_ActiveSlots) { if (itemSlot.m_Item == item) { Food food = (Food)itemSlot.m_Item; FoodInfo info = (FoodInfo)itemSlot.m_Item.m_Info; return(food.m_ProcessDuration / this.GetProcessingTime(info)); } } return(0f); }
public void Insert(FoodInfo model) { SqlHelper.ExecuteNonQuery(@"insert into FoodInfo(FoodBusinessID,FoodName,FoodImgURL,FoodImage, FoodPrice,FoodKind,FoodTaste) values(@FoodBusinessID,@FoodName,@FoodImgURL, @FoodImage,@FoodPrice,@FoodKind,@FoodTaste)", new SqlParameter("@FoodBusinessID", model.FoodBusinessID), new SqlParameter("@FoodName", model.FoodName), new SqlParameter("@FoodImgURL", model.FoodImgURL), new SqlParameter("@FoodImage", model.FoodImage), new SqlParameter("@FoodPrice", model.FoodPrice), new SqlParameter("@FoodKind", model.FoodKind), new SqlParameter("@FoodTaste", model.FoodTaste)); //数据库中默认值为 0 //new SqlParameter("@FoodIsdeleted", model.FoodIsdeleted)); }
private void ShipItem(Player player, FoodInfo foodInfo) { Bag bag = player.playerController.bag; bag.Remove(foodInfo, 1); int shipValue = foodInfo.shipValue; if (StoryProgress.Instance.GetInt("CarrotDemand") == 1 && foodInfo.name.Equals("Carrot")) { shipValue = (int)(shipValue * carrotDemandMultiplier); StoryProgress.Instance.Set("CarrotDemandShip", StoryProgress.Instance.GetInt("CarrotDemandShip") + 1); } ScoreManager.Instance.moneyInBin += shipValue; }
public FoodInfo[] GetByName(string name, Guid id) { DataTable table = SqlHelper.ExecuteDataTable(@"select * from FoodInfo where FoodName like @name and FoodBusinessID=@Bid and FoodIsdeleted=0", new SqlParameter("@name", "%"+name+"%"), new SqlParameter("@Bid", id)); if (table.Rows.Count <= 0) { return null; } else { FoodInfo[] dt = new FoodInfo[table.Rows.Count]; for (int i = 0; i < table.Rows.Count; i++) { dt[i] = ToModel(table.Rows[i]); } return dt; } }
public static void UpdateFood(FoodInfo food) { food.FoodIsdeleted = false; new FoodInfoDAL().Update(food); }
public static void InsertFood(FoodInfo food) { new FoodInfoDAL().Insert(food); }
public FoodInfo[] ListAll(Guid id,string kind) { DataTable table = SqlHelper.ExecuteDataTable(@"select * from FoodInfo where FoodIsdeleted=0 and FoodBusinessID=@FoodBusinessID and FoodKind=@Kind", new SqlParameter("@FoodBusinessID",id), new SqlParameter("@Kind",kind)); FoodInfo[] dt = new FoodInfo[table.Rows.Count]; for (int i = 0; i < table.Rows.Count; i++) { dt[i] = ToModel(table.Rows[i]); } return dt; }
private FoodInfo ToModel(DataRow row) { FoodInfo model = new FoodInfo(); model.FoodID = (System.Guid)SqlHelper.FromDBValue(row["FoodID"]); model.FoodBusinessID = (System.Guid)SqlHelper.FromDBValue(row["FoodBusinessID"]); model.FoodName = (System.String)SqlHelper.FromDBValue(row["FoodName"]); model.FoodImage = (System.Byte[])SqlHelper.FromDBValue(row["FoodImage"]); model.FoodPopularIndex = (System.Int32)SqlHelper.FromDBValue(row["FoodPopularIndex"]); model.FoodPrice = (System.Int32)SqlHelper.FromDBValue(row["FoodPrice"]); model.FoodTaste = (System.String)SqlHelper.FromDBValue(row["FoodTaste"]); model.FoodKind = (System.String)SqlHelper.FromDBValue(row["FoodKind"]); model.FoodImgURL = (System.String)SqlHelper.FromDBValue(row["FoodImgURL"]); //数据库中默认值为 0 //model.FoodIsdeleted = (System.Boolean)SqlHelper.FromDBValue(row["FoodIsdeleted"]); return model; }
public void Update(FoodInfo model) { SqlHelper.ExecuteNonQuery(@"UPDATE FoodInfo set FoodName = @FoodName, FoodImgURL = @FoodImgURL, FoodImage = @FoodImage, FoodPrice = @FoodPrice, FoodTaste = @FoodTaste, FoodIsdeleted = @FoodIsdeleted WHERE FoodID=@FoodID", new SqlParameter("@FoodID", model.FoodID), new SqlParameter("@FoodName", model.FoodName), new SqlParameter("@FoodImgURL", model.FoodImgURL), new SqlParameter("@FoodImage", model.FoodImage), new SqlParameter("@FoodPrice", model.FoodPrice), new SqlParameter("@FoodTaste", model.FoodTaste), new SqlParameter("@FoodIsdeleted", model.FoodIsdeleted)); }
public FoodPage( Tag tag, string mainText, FoodInfo[] food, string buttonText, string eatMainText, string postEatButtonText, bool singleChoice ) { this.tag = tag; this.mainText = mainText; this.food = food; this.singleChoice = singleChoice; this.buttonText = buttonText; this.eatMainText = eatMainText; this.postEatButtonText = postEatButtonText; }
private IEnumerator EatFood( string mainText, FoodInfo[] food, string buttonText ) { Set( mainText ); for( int i = 0; i < food.Length; ++i ) { yield return new WaitForSeconds( 1.0f ); yield return StartCoroutine( AddKcal( food[ i ].kcal ) ); } Set( mainText, new ButtonInfo( buttonText ) ); selectedButton = -1; yield return StartCoroutine( WaitForButton() ); }