public bool DeleteDish(string dishId) { Dishes dish = null; bool status = false; try { dish = _context.Dishes.Find(dishId); if (dish != null) { _context.Dishes.Remove(dish); _context.SaveChanges(); status = true; } else { status = false; } } catch (Exception) { status = false; } return(status); }
public string UpdateDish(JObject data) { try { Dishes d = new Dishes(); dynamic json1 = data; d.Name = json1.Name; d.Id = json1.Id; d.ImageSrc = json1.ImageSrc; d.Script = json1.Script; d.AlphaConstant = json1.AlphaConstant; string time = json1.TimeToRun; string[] s = time.Split(':'); d.TimeToRun = new TimeSpan(0, int.Parse(s[0]), int.Parse(s[1])); using (var ctx = new PicardDb()) { ctx.Entry(d).State = EntityState.Modified; ctx.SaveChanges(); return(getAllDishes()); } } catch (Exception err) { return(getAllDishes()); } }
public async Task <IActionResult> PutDishes(long id, Dishes dishes) { if (id != dishes.Id) { return(BadRequest()); } _context.Entry(dishes).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DishesExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void Save(Dishes recipes) { using (var _db = new SQLiteConnection(_dbPath)) { _db.InsertOrReplace(recipes); } }
public void DeleteAll() { foreach (Dish dish in Dishes) { Dishes.Clear(); } }
public async Task <IActionResult> Edit(int?id) { if (_userManager.GetUserId(User) == adminId) { if (id == null) { return(NotFound()); } Dishes dishes = await _context.Dishes.Include(i => i.Image).FirstOrDefaultAsync(i => i.Id == id); if (dishes != null) { SelectList brands = new SelectList(_context.Categories, "Id", "Name", dishes.CategoryId); ViewBag.Brands = brands; SelectList tags = new SelectList(_context.Tags, "Id", "Name", dishes.TagId); ViewBag.Tags = tags; return(View(dishes)); } return(RedirectToAction("Index")); } else { return(Permission()); } }
public IActionResult EditDish(int DishId) { Dishes ToEdit = dbContext.Dishes .FirstOrDefault(dish => dish.DishId == DishId); return(View("EditDish", ToEdit)); }
public BonusViewModel() { Dishes.Clear(); Dishes.AddItems(_unitOfWork.Dishes.GetAll()); ApplyAction = new Command(OnApplyActionExecute, OnApplyActionCanExecute); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Name_dish,TypesID,description")] Dishes dishes) { if (id != dishes.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(dishes); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DishesExists(dishes.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["TypesID"] = new SelectList(_context.Types, "ID", "ID", dishes.TypesID); return(View(dishes)); }
public IActionResult Display(int DishId) { Dishes thisDish = dbContext.Dishes .SingleOrDefault(dish => dish.DishId == DishId); return(View("Display", thisDish)); }
internal static void Show_AddIngredientsView(Dishes dish) { Show_WaitView("Cargando las lista de productos"); //TODO select all products from db List <Products> products; using (var db = App.DbFactory.Open()) { products = db.Select <Products>(); } Current.Dispatcher.Invoke(() => { ParentView.Current.ProductCatalogBtn.IsEnabled = false; ParentView.Current.DishesCatalogBtn.IsEnabled = false; ParentView.Current.ConfigurationBtn.IsEnabled = false; var oldView = Current.Transition.Content as UserControl; var view = new AddIngredientsView(dish, products); Current.Transition.Content = view; ViewLoaded?.Invoke(view); App.Log.Message($"AddIngredientsView. Dish: {dish.ToString()}\nProducts: {products.Serialize(LibreR.Models.Enums.Serializer.OneLine)}", "VIEW-LOADED"); if (!(oldView is WaitView)) { ViewUnloaded?.Invoke(oldView); } }); }
public static Dishes printdishes(Dishes dish) { Console.WriteLine(dish); //if(dish.HasFlag(Dishes.DESSERT)) // Console.WriteLine("yes dessert"); return(dish | Dishes.SURPRISE); }
public IActionResult Update(Dishes newDish) { if (ModelState.IsValid) { System.Console.WriteLine("///////////////////"); Dishes UpdateDish = dbContext.Dishes.SingleOrDefault(Update => Update.UserId == newDish.UserId); UpdateDish.Chef = Request.Form["Chef"]; UpdateDish.Name = Request.Form["Name"]; // Int32.TryParse(Label1.Text, out imageWidth int Cals = 0; Int32.TryParse(Request.Form["Calories"], out Cals); UpdateDish.Calories = Cals; int Taste = 0; Int32.TryParse(Request.Form["Tastiness"], out Taste); UpdateDish.Tastiness = Taste; UpdateDish.Text = Request.Form["Text"]; dbContext.SaveChanges(); System.Console.WriteLine("?????????????????"); System.Console.WriteLine(Request.Form["Calories"]); return(RedirectToAction("Index")); } else { System.Console.WriteLine("**********************"); return(View("EditDish")); } ; }
public IActionResult EditDish(int tempId) { System.Console.WriteLine("*****************************************************************************************************************************Im starting to edit here"); Dishes singleDish = dbContext.Dishes.SingleOrDefault(x => x.DishId == tempId); return(View(singleDish)); }
public IActionResult ViewSingleDish(int id) { Dishes DishToShow = dbContext.Dishes.FirstOrDefault(a => a.Id == id); return(View(DishToShow)); }
public IActionResult EditDish(Dishes Dish) { Console.WriteLine($"The edit dish method is running"); dbContext.Dishes.Update(Dish); dbContext.SaveChanges(); return(RedirectToAction("Index")); }
public IActionResult CRUDelicious(Dishes importDishes) { List <Dishes> allDishes = dbContext.Dishes.ToList(); // IEnumerable<Dishes> allDishes1 = allDishes.Where(p => p.DishId > 0); return(View("CRUDelicious", allDishes)); }
public void Save(Dishes dish) { Dishes maxIdDish = FakeList.OrderByDescending(d => d.Id).FirstOrDefault(); dish.Id = maxIdDish.Id + 1; FakeList.Add(dish); }
public void ProcessOrder() { IOrder order = new Order(); var inputList = Helpers.CreateInputList(order.InputString); Assert.IsFalse(Dishes.ProcessDishes(null, "")); }
public void TestMethod1() { string filePath = @"I:\srouce\DishDatabase——dishes.txt"; string[] lines = File.ReadAllLines(filePath); List <string[]> rows = lines.AsParallel().Skip(1).Select(l => l.Split('\t')).ToList(); DailyDishHelper ddh = new DailyDishHelper(); foreach (var item in rows) { Dishes dishes = new Dishes() { Id = Guid.NewGuid().ToString(), DishName = item[0], FirstTaste = item[1], SecondTaste = item[2], Explain = item[3], MainIngredients = item[4], Accessory = item[5], PracticeUrl = item[6], Status = 1, CreateTime = DateTime.Now }; ddh.ImportDishes(dishes); } }
protected void ShowAll(string name, string category) { CollectionRecipe dishes = new CollectionRecipe(); Dishes dishesBL = new Dishes(category); dishes = dishesBL.ShowAllName(); Console.WriteLine(name + ", plase write number of " + category + " to see all information"); Console.WriteLine(); for (int i = 0; i < dishes.ListRecipe.Count; i++) { Console.WriteLine(i + 1 + " : " + dishes.ListRecipe[i].Name); } int choice = Convert.ToInt32(Console.ReadLine()); if (choice < 0 || choice > dishes.ListRecipe.Count) { Console.WriteLine("incorrect input"); } else { ShowRecipe(name, category, choice - 1); } }
public async Task <IActionResult> Edit(long id, [Bind("Id,Title,Description,Price,Calories,Discount,FkDishCategories")] Dishes dishes) { if (id != dishes.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(dishes); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DishesExists(dishes.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["FkDishCategories"] = new SelectList(_context.DishCategories, "Id", "Title", dishes.FkDishCategories); return(View(dishes)); }
public int ImportDishes(Dishes dishes) { int ret = 0; SQLiteHelper sh = new SQLiteHelper(); StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Dishes("); strSql.Append("Id,DishName,FirstTaste,SecondTaste,Explain,MainIngredients,Accessory,PracticeUrl,Status,CreateTime)"); strSql.Append(" values ("); strSql.Append("@Id,@DishName,@FirstTaste,@SecondTaste,@Explain,@MainIngredients,@Accessory,@PracticeUrl,@Status,@CreateTime)"); SQLiteParameter[] parameters = { sh.MakeSQLiteParameter("@Id", DbType.String, dishes.Id), sh.MakeSQLiteParameter("@DishName", DbType.String, dishes.DishName), sh.MakeSQLiteParameter("@FirstTaste", DbType.String, dishes.FirstTaste), sh.MakeSQLiteParameter("@SecondTaste", DbType.String, dishes.SecondTaste), sh.MakeSQLiteParameter("@Explain", DbType.String, dishes.Explain), sh.MakeSQLiteParameter("@MainIngredients", DbType.String, dishes.MainIngredients), sh.MakeSQLiteParameter("@Accessory", DbType.String, dishes.Accessory), sh.MakeSQLiteParameter("@PracticeUrl", DbType.String, dishes.PracticeUrl), sh.MakeSQLiteParameter("@Status", DbType.String, dishes.Status), sh.MakeSQLiteParameter("@CreateTime", DbType.DateTime, dishes.CreateTime) }; if (sh.ExecuteSql(strSql.ToString(), parameters) >= 1) { ret = 1; } return(ret); }
public async Task <ActionResult <Dishes> > PostDishes(Dishes dishes) { _context.DishesItems.Add(dishes); await _context.SaveChangesAsync(); return(CreatedAtAction("GetDishes", new { id = dishes.Id }, dishes)); }
public Dishes QueryDishesById(string dishesId) { SQLiteHelper sh = new SQLiteHelper(); StringBuilder strSql = new StringBuilder(); strSql.Append("select * FROM Dishes"); strSql.Append(" where Id=@Id "); SQLiteParameter[] parameters = { sh.MakeSQLiteParameter("@Id", DbType.String, dishesId) }; Dishes list = sh.Query(strSql.ToString(), parameters).Tables[0].AsEnumerable().Select(r => new Dishes { Id = r[0].ToString(), DishName = r[1].ToString(), FirstTaste = r[2].ToString(), SecondTaste = r[3].ToString(), Explain = r[4].ToString(), MainIngredients = r[5].ToString(), Accessory = r[6].ToString(), PracticeUrl = r[7].ToString(), Status = Int32.Parse(r[8].ToString()), CreateTime = DateTime.Parse(r[9].ToString()) }).ToList <Dishes>()[0]; return(list); }
public bool UpdateDish(Dishes dish) { bool status = false; Dishes found = _context.Dishes.Find(dish.Did); try { if (found != null) { found.Name = dish.Name; found.Status = dish.Status; found.CatId = dish.CatId; found.Description = dish.Description; found.Price = dish.Price; _context.SaveChanges(); status = true; } else { status = false; } } catch (Exception) { status = false; } return(status); }
public DishesModel GetDishByUser(string openId) { List <DishScore> score = QueryScoreByUser(openId); if (score.Count == 0) { GetFactorScore(openId); score = QueryScoreByUser(openId); } DishScore dishscore = score.OrderByDescending(r => r.Score).ThenBy(r => r.DishesId).First(); Dishes dish = QueryDishesById(dishscore.DishesId); DishesModel model = new DishesModel() { Id = dishscore.DishesId, SecondTaste = dish.SecondTaste, Status = dish.Status, Accessory = dish.Accessory, CreateTime = dish.CreateTime, DishName = dish.DishName, Explain = dish.Explain, FirstTaste = dish.FirstTaste, MainIngredients = dish.MainIngredients, PracticeUrl = dish.PracticeUrl, Score = dishscore.Score }; return(model); }
public string CreateNewDish(JObject data) { Dishes d = new Dishes(); dynamic json1 = data; d.Name = json1.dishname; d.ImageSrc = json1.imagesrc; d.TimeToRun = json1.TimeToRun; d.Script = json1.script; d.AlphaConstant = json1.AlphaConstant; string time = json1.TimeToRun; string[] s = time.Split(':'); d.TimeToRun = new TimeSpan(0, int.Parse(s[0]), int.Parse(s[1])); using (var ctx = new PicardDb()) { ctx.Entry(d).State = EntityState.Added; ctx.SaveChanges(); ctx.Entry(d).GetDatabaseValues(); int id = d.Id; return(id.ToString()); } }
public IActionResult AddDish(Dishes newDish) { dbContext.Add(newDish); dbContext.SaveChanges(); // Console.WriteLine("WHASSUP FOOOOOOOOOOOOOOOOOOOOOOOOOO"); return(RedirectToAction("Index")); }
private void RemoveDish(Dish dish) { if (dish != null) { Dishes.Remove(dish); } }
//Add an item to the menu include the name and the money. private void AddDish(object sender, RoutedEventArgs e) { Dishes dish = new Dishes(); try { dish.DishName = DishNameA.Text; dish.Money = Convert.ToDecimal( Convert.ToInt32((decimal.Parse(MoneyA.Text)) * 100) )/100; Db.db.Dishes.Add(dish); Db.db.SaveChanges(); AddError.Content = ""; DishNameA.Text = ""; MoneyA.Text = ""; } catch { AddError.Content = "Your input has something wrong. Try again"; } ShowDish(); }