public void addMenuItem() { Console.Write("Enter Meal name: "); string mealName = Console.ReadLine(); Console.Write("Enter a Meal number: "); int mealNumber = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter the Meal description: "); string mealDescription = Console.ReadLine(); Console.Write("Enter Ingredients and type done when you are done entering the ingredients: "); string ingredient = ""; List <string> ingredientList = new List <string>(); while (ingredient.ToLower() != "done") { ingredient = Console.ReadLine(); if (ingredient.ToLower() != "done") { ingredientList.Add(ingredient); } } Console.Write("Price of the meal: "); double mealprice = Convert.ToDouble(Console.ReadLine()); Menu item = new Menu(mealNumber, mealName, mealDescription, ingredientList, mealprice); mr.Add(item); }
public void Test_View() { MenuRepository mr = new MenuRepository(); Menu m1 = new Menu(1, "Coffee", "Black Coffe", null, 1); Menu m2 = new Menu(2, "Bread", "Wheat Bread", null, 2); mr.Add(m1); mr.Add(m2); Assert.IsTrue(mr.MenuList.Count == 2); }
protected void btnAddMenu_Click(object sender, EventArgs e) { var repository = new MenuRepository(); MenuModel mnu = new MenuModel(); //mnu.CommunityId = Convert.ToInt32(txtCommunityId.Text); mnu.CommunityId = Convert.ToInt32(ddlCommunity.SelectedValue); mnu.ParentId = Convert.ToInt32(ddlParentMenu.SelectedValue); mnu.IsBoard = chkIsBoard.Checked; mnu.MenuName = txtMenuName.Text; mnu.MenuPath = txtMenuPath.Text; mnu.Target = ddlTarget.SelectedValue; mnu.IsVisible = optIsVisible.SelectedValue == "1" ? true : false; // ParentId가 0이면 가장 나중에 서브 메뉴이면 해당 메뉴 +1 순서에 mnu.MenuOrder = repository.UpdateMenuOrder(mnu.ParentId, mnu.CommunityId); mnu.BoardAlias = hdnBoardAlias.Value; repository.Add(mnu); Response.Redirect(Request.RawUrl); }
public void Test_Add() { MenuRepository mr = new MenuRepository(); Menu m1 = new Menu(1, "Coffee", "Black Coffe", null, 1); mr.Add(m1); Assert.IsTrue(mr.MenuList.Count == 1); }
private void Add(List <Menu_M._Menus> menus) { _repository.Add(new Menu_M { restaurant = "蜂鳥食堂", website = "https://www.hummingfood.com/menu", updateDate = DateTime.Now, menus = menus, }); }
public static void InsertMenu(MenuModelView model) { Menu objretorno = new Menu(); //faz o de para: objModelView para objEntity Mapper.CreateMap <MenuModelView, Menu>(); var objtpprod = Mapper.Map <Menu>(model); MenuRepository tpprod = new MenuRepository(); tpprod.Add(objtpprod); tpprod.Save(); }
public ActionResult CreateMenu(NewMenuViewModel model) { var context = new AppSecurityContext(); var menuRepository = new MenuRepository(context); if (ModelState.IsValid) { var menu = mapper.Map <AppMenu>(model); menuRepository.Add(menu); context.SaveChanges(); return(RedirectToAction("Menus")); } return(View()); }
public async Task <IHttpActionResult> PostMenu(MenuDTO menuDTO) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var dishes = menuDTO.Dishes.Select(dish => DishRepository.GetByIdAsync(dish.Id).Result).ToList(); var model = MenuRepository.GetMenuFromDTO(menuDTO, dishes); MenuRepository.Add(model); //await UnitOfWork.CommitAsync(); return(CreatedAtRoute("DefaultApi", new { id = menuDTO.Id }, menuDTO)); }
public void Add(Menu entity) { _menuRepository.Add(entity); }
public void InitFiles(int version) { var updObjectId = "fb52e98c-8369-4a8b-86ab-69a166fd29c3"; string contentRootPath = _env.ContentRootPath; //var SectionJSON = System.IO.File.ReadAllText(contentRootPath + "/DataFiles/Layout/Sections.json"); //var TileJSON = System.IO.File.ReadAllText(contentRootPath + "/DataFiles/Layout/tiles.json"); var MenuJSON = string.Empty; // System.IO.File.ReadAllText(contentRootPath + "/DataFiles/Layout/Menus.json"); var assembly = Assembly.Load("infusync.Embedded"); var resourceStream = assembly.GetManifestResourceStream("infusync.Embedded.DataFiles.Layout.menus.json"); using (var reader = new StreamReader(resourceStream, Encoding.UTF8)) { MenuJSON = reader.ReadToEnd(); } //var sections = JsonConvert.DeserializeObject<IEnumerable<Section>>(SectionJSON); //var tiles = JsonConvert.DeserializeObject<IEnumerable<Tile>>(TileJSON); var menus = JsonConvert.DeserializeObject <IEnumerable <Menu> >(MenuJSON); //var menus = new JavaScriptSerializer().Deserialize<IEnumerable<Menu>>(MenuJSON); foreach (var client in menus.ToList()) { client.Id = ObjectId.GenerateNewId(); client.UserSign = updObjectId; client.CreateDate = DateTime.Now; client.UpdateDate = DateTime.Now; client.Status = "A"; foreach (var sec in client.Securables) { sec.UserSign = updObjectId; sec.CreateDate = DateTime.Now; sec.UpdateDate = DateTime.Now; sec.Status = "A"; sec.MenuId = client.Id; sec.Id = ObjectId.GenerateNewId(); } var menuI = _context.GetAll().Where(arg => arg.Code == client.Code).FirstOrDefault(); if (menuI == null) { _context.Add(client, updObjectId); } } //var updObjectId = "fb52e98c-8369-4a8b-86ab-69a166fd29c3"; //string contentRootPath = _env.ContentRootPath; //var SectionJSON = System.IO.File.ReadAllText(contentRootPath + "/DataFiles/Layout/Sections.json"); //var TileJSON = System.IO.File.ReadAllText(contentRootPath + "/DataFiles/Layout/tiles.json"); //var MenuJSON = System.IO.File.ReadAllText(contentRootPath + "/DataFiles/Layout/Menus.json"); //var sections = JsonConvert.DeserializeObject<IEnumerable<Section>>(SectionJSON); //var tiles = JsonConvert.DeserializeObject<IEnumerable<Tile>>(TileJSON); //var menus = JsonConvert.DeserializeObject<IEnumerable<Menu>>(MenuJSON); ////foreach (var item in sections) ////{ //// if (!_context.Sections.Any(c => c.Id == item.Id)) //// { //// item.UserSign = updObjectId; //// item.CreateDate = DateTime.Now; //// item.UpdateDate = DateTime.Now; //// item.Status = "A"; //// _context.Sections.Add(item); //// } ////} ////foreach (var item in tiles) ////{ //// if (!_context.Tiles.Any(c => c.Id == item.Id)) //// { //// item.UserSign = updObjectId; //// item.CreateDate = DateTime.Now; //// item.UpdateDate = DateTime.Now; //// item.Status = "A"; //// _context.Tiles.Add(item); //// } ////} //foreach (var item in menus) //{ // if (!menus.Any(c => c.Id == item.Id)) // { // item.Id = ObjectId.GenerateNewId(); // item.UserSign = updObjectId; // item.CreateDate = DateTime.Now; // item.UpdateDate = DateTime.Now; // item.Status = "A"; // //foreach (var sec in item.Securables) // //{ // // sec.UserSign = updObjectId; // // sec.CreateDate = DateTime.Now; // // sec.UpdateDate = DateTime.Now; // // sec.Status = "A"; // // //sec.Id = new ObjectId(); // //} // _repository.Add(item); // } //} }