//取出建立飲料細節的ViewModel public static Add2_Drinks_detail Add2_NewDrinkDetails(int ID) { NewDrinkDB db = new NewDrinkDB(); Menu MenuName = db.Menus.Find(ID); //取出店家尺寸的ViewModel IList <Add2_Drinks_Size> mySize = Add2_NewMenuAbout.Add2mySize(ID); //取出店家尺寸的ViewModel (下拉選單) List <SelectListItem> mySizeD = ManagerModels.mySize(ID); //取出飲料甜度的ViewModel IList <SelectListItem> mySweet = ManagerModels.mySweet(ID); //取出飲料冰度的ViewModel IList <SelectListItem> myIce = ManagerModels.myIce(ID); //取出飲料配料的ViewModel IList <SelectListItem> myAddItem = ManagerModels.myAddItem(ID); db.Dispose(); return(new Add2_Drinks_detail() { DrinkName = "", Add2_Drinks_Sizes = mySize, SizeType = mySizeD, Sweet = mySweet, IceHot = myIce, AddItem = myAddItem, Bathus = "", DrinkPrice = 0, SizeTypeM = "" }); }
//取出使用者輸入的飲料設定 //取出輸入的甜度 public static IList <SelectListItem> TakeDrinksSweet(IList <SelectListItem> sweet, int MenuID) { IList <SelectListItem> mySweet = ManagerModels.mySweet(MenuID); foreach (var item in sweet) { foreach (var sweetitem in mySweet) { if (item.Value == sweetitem.Value) { sweetitem.Selected = true; } } } return(mySweet); }
//取出動態新增飲料細節的ViewModel public static DrinkDetails PartialAddDrinkDetails(int ID) { //取出飲料尺寸的ViewModel List <SelectListItem> mySize = ManagerModels.mySize(ID); //取出飲料甜度的ViewModel IList <SelectListItem> mySweet = ManagerModels.mySweet(ID); //取出飲料冰度的ViewModel IList <SelectListItem> myIce = ManagerModels.myIce(ID); //取出飲料冰度的ViewModel IList <SelectListItem> myAddItem = ManagerModels.myAddItem(ID); return(new DrinkDetails() { SizeType = mySize, Sweet = mySweet, IceHot = myIce, AddItem = myAddItem, DrinkPrice = 0 }); }
//取出建立飲料細節的ViewModel public static AddDrinkDetails CurrentAddDrinkDetails(int ID) { NewDrinkDB db = new NewDrinkDB(); Menu MenuName = db.Menus.Find(ID); //取出飲料尺寸的ViewModel List <SelectListItem> mySize = ManagerModels.mySize(ID); //取出飲料甜度的ViewModel IList <SelectListItem> mySweet = ManagerModels.mySweet(ID); //取出飲料冰度的ViewModel IList <SelectListItem> myIce = ManagerModels.myIce(ID); //取出飲料配料的ViewModel IList <SelectListItem> myAddItem = ManagerModels.myAddItem(ID); db.Dispose(); return(new AddDrinkDetails() { MenuID = MenuName.ID, MenuName = MenuName.MenuName, DrinkDetails = new List <DrinkDetails>() { new DrinkDetails() { DrinkType = "", DrinkName = "", SizeType = mySize, Sweet = mySweet, IceHot = myIce, AddItem = myAddItem, DrinkPrice = 0 } } }); }
//取出返回動態新增飲料細節的ViewModel public static AddDrinkDetails BackAddDrinkDetails(AddDrinkDetails addDks) { //取出飲料尺寸的ViewModel List <SelectListItem> mySize = ManagerModels.mySize(addDks.MenuID); //取出飲料甜度的ViewModel IList <SelectListItem> mySweet = ManagerModels.mySweet(addDks.MenuID); //取出飲料冰度的ViewModel IList <SelectListItem> myIce = ManagerModels.myIce(addDks.MenuID); //取出飲料冰度的ViewModel IList <SelectListItem> myAddItem = ManagerModels.myAddItem(addDks.MenuID); foreach (var item in addDks.DrinkDetails) { item.SizeType = mySize; item.Sweet = mySweet; item.IceHot = myIce; item.AddItem = myAddItem; } return(addDks); }