private void updateAccountBtn_Click(object sender, EventArgs e) { Food aa = new Food(); aa.FoodId = this.textBox1.Text; aa.FoodName = this.textBox2.Text; aa.FoodPrice = float.Parse(this.textBox4.Text); FoodRepository re = new FoodRepository(); if (re.Update(aa)) { // List<Account> accList = accRepo.GetAllAccounts(); // this.accountGridView.DataSource = accList MessageBox.Show("Update Complete"); textBox1.Text = " "; textBox2.Text = " "; textBox4.Text = " "; } else { MessageBox.Show("Update Not Complete", "Error"); } }
private void loadAccountBtn_Click(object sender, EventArgs e) { FoodRepository accRepo = new FoodRepository(); List <Food> accList = accRepo.GetAllFoods(); this.FoodGridView.DataSource = accList; }
public ActionResult Details(int Id) { FoodRepository foodRepository = new FoodRepository(); Food Fooddetail = foodRepository.FoodDetails(Id); return(View(Fooddetail)); }
public IViewComponentResult Invoke() { FoodRepository foodRepository = new FoodRepository(); var foodlist = foodRepository.TList(); return(View(foodlist)); }
private void AddProductButton_Click(object sender, EventArgs e) { FoodRepository _DataAccess = new FoodRepository(); /*THIS IS THE MAIN CODE FOR HASHING*/ /*initializing memory stream class for creating a stream of binary numbers*/ MemoryStream ms = new MemoryStream(); /*saving the image in raw format from picture box*/ ProductPictureBox.Image.Save(ms, ProductPictureBox.Image.RawFormat); /*Array of Binary numbers that have been converted*/ byte[] ProductPicture = ms.GetBuffer(); /*closing the memory stream*/ ms.Close(); /*HASHING END HERE*/ if (_DataAccess.AddNewProductToDatabase(ProductNameBox.Text, Convert.ToDecimal(ProductPriceBox.Text), _DataAccess.ReturnCategoryID(ProductCategoryComboBox.SelectedItem.ToString()), ProductDescriptionRBox.Text, ProductPicture)) { MessageBox.Show("Product Added"); } else { MessageBox.Show("Product Not Added"); } }
private void btnAddCategory_Click(object sender, EventArgs e) { AddCategory _AddCategory = new AddCategory(); //Retreive CatgeoriesAgain to Show on CategoriesFlow Panel if (_AddCategory.ShowDialog() == DialogResult.OK) { CategoriesFlowPanel.Controls.Clear(); FoodRepository _DataAccess = new FoodRepository(); ArrayList AllCategories = _DataAccess.RetreiveAllCategoriesFromDatabase(); foreach (Food Category in AllCategories) { Button btn = new Button(); btn.Text = Category.FCategory; btn.Size = new System.Drawing.Size(80, 80); btn.ForeColor = Color.Black; MemoryStream ms = new MemoryStream(Category.CPicture); btn.Image = Image.FromStream(ms); btn.Image = new Bitmap(btn.Image, btn.Size); btn.Tag = Category.FId; CategoriesFlowPanel.Controls.Add(btn); btn.Click += CategoryButtonClick; } } }
static void Main(string[] args) { Oven oven = new GasOven(); oven.Heat(); Food food = new Food(); food.Name = "Salat"; food.Price = 153; food.Ingredients = new List <Ingridient>(); food.Ingredients.Add(new Ingridient { Fats = 15.3, Name = "Truf", Protein = 15.6 }); Food food1 = food; Console.WriteLine($"{food.GetHashCode()}, {food1.GetHashCode()}"); BaseRepositry <Food> foodRepository = new FoodRepository(); foodRepository.Create(food); Drinks drinks = new Drinks { Name = "Beer", Price = 10 }; BaseRepositry <Drinks> drinksRepository = new DrinksRepository(); drinksRepository.Create(drinks); }
void CategoryButtonClick(object sender, EventArgs e) { ProductsFlowPanel.Controls.Clear(); Button btn = (Button)sender; int CategoryID = Convert.ToInt32(btn.Tag); FoodRepository _DataAccess = new FoodRepository(); foreach (Food foods in _DataAccess.RetreiveProductsFromCategory(CategoryID)) { Button ProductButton = new Button(); ProductButton.Text = foods.FName; ProductButton.Size = new System.Drawing.Size(80, 80); ProductButton.ForeColor = Color.Black; MemoryStream ms = new MemoryStream(foods.FPicture); ProductButton.Image = Image.FromStream(ms); ProductButton.Image = new Bitmap(ProductButton.Image, ProductButton.Size); ProductButton.Tag = foods.FId; ProductsFlowPanel.Controls.Add(ProductButton); ProductButton.Click += ProductButton_Click; //ProductButton.MouseClick += ProductButton_MouseClick; } }
public IViewComponentResult Invoke(int id) { FoodRepository foodRepository = new FoodRepository(); var foodlist = foodRepository.List(x => x.CategoryID == id); return(View(foodlist)); }
private void Entry_Click(object sender, EventArgs e) { add(comboBox1.SelectedItem.ToString(), qtext.Text); FoodRepository f = new FoodRepository(); total = f.GetFoods(comboBox1.Text).FoodPrice *(float.Parse(qtext.Text)) + total; }
public async Task AddNewFood() { //arrange var options = new DbContextOptionsBuilder <FoodContext>().UseInMemoryDatabase(databaseName: "FoodTestDb").Options; using (var dbContext = new FoodContext(options)) { var quoteRepository = new FoodRepository(dbContext); //act dbContext.Foods.Add(new Food() { Name = "Orange", Amount = 1, Calorie = 120 }); dbContext.SaveChanges(); //assert string expected = "Orange"; var quote = await dbContext.Foods.FirstOrDefaultAsync(f => f.Name.Equals("Orange")); Assert.Equal(expected, quote.Name); } }
public async Task <List <Recipe> > GetRecipes() { List <Recipe> recipes = new List <Recipe>(); List <Models.DB.Recipe> fromDB = await this.foodDatabase.GetRecipes(); foreach (var recipeFromDB in fromDB) { Recipe recipe = ConvertFromDb(recipeFromDB); recipes.Add(recipe); List <Models.DB.RecipeItem> items = await this.foodDatabase.GetRecipeItems(recipeFromDB.Id); foreach (var recipeItemDB in items) { Models.DB.Food foodDb = await this.foodDatabase.FoodById(recipeItemDB.FoodId); RecipeItem recipeItem = ConvertFromDb(recipeItemDB); recipeItem.Food = FoodRepository.ConvertFromDb(foodDb); recipe.Items.Add(recipeItem); } } return(recipes); }
private void ProductCategoryComboBox_SelectedIndexChanged(object sender, EventArgs e) { ProductsGridView.Rows.Clear(); if (ProductCategoryComboBox.SelectedIndex == 0) { FoodRepository _DataAccess = new FoodRepository(); foreach (Food ProductDetail in _DataAccess.RetreiveAllProducts()) { ProductsGridView.Rows.Add(ProductDetail.FId, ProductDetail.FName, ProductDetail.FPrice, ProductDetail.FCategory, ProductDetail.FDescription, ProductDetail.FPicture); } } else if (ProductCategoryComboBox.SelectedIndex > 0) { string CategoryName = ProductCategoryComboBox.SelectedItem.ToString(); FoodRepository _DataAccess = new FoodRepository(); int CategoryID = _DataAccess.ReturnCategoryID(CategoryName); foreach (Food ProductDetail in _DataAccess.RetreiveProductsFromCategory(CategoryID)) { ProductsGridView.Rows.Add(ProductDetail.FId, ProductDetail.FName, ProductDetail.FPrice, CategoryName, ProductDetail.FDescription, ProductDetail.FPicture); } } }
void ProductButton_Click(object sender, EventArgs e) { Button ProductButton = sender as Button; FoodRepository _DataAccess = new FoodRepository(); int ProductID = Convert.ToInt32(ProductButton.Tag); Food ProductDetails = _DataAccess.RetreiveProductDetails(ProductID); if (CheckProductAlreadyAdded(ProductID)) { // MessageBox.Show("Product Alraedy Exists in Datagrid view at Index : " + RowIndex); int Quantity = Convert.ToInt32(ProductsGridView.Rows[RowIndex].Cells["ProductQuantityColumn"].Value); decimal Price = Convert.ToInt32(ProductsGridView.Rows[RowIndex].Cells["ProductPriceColumn"].Value); Quantity++; /////////////<Do thisssss...... Important.. Have decimal part in the total price> double TotalPrice = Convert.ToDouble(Quantity * Price); ProductsGridView.Rows[RowIndex].Cells["ProductQuantityColumn"].Value = Quantity; ProductsGridView.Rows[RowIndex].Cells["TotalPriceColumn"].Value = TotalPrice; TotalBillBox.Text = CalculateTotalBill(ProductsGridView).ToString(); } else { ProductsGridView.Rows.Add(ProductID, ProductDetails.FName, ProductDetails.FPrice, 1, ProductDetails.FPrice * 1); TotalBillBox.Text = CalculateTotalBill(ProductsGridView).ToString(); } }
public UnitOfWork(ApplicationDbContext context) { _context = context; Foods = new FoodRepository(_context); Products = new ProductRepository(_context); Recipes = new RecipeRepository(_context); Shoppinglists = new ShoppinglistRepository(_context); }
private void Search_Click(object sender, EventArgs e) { string text = this.textBox5.Text; FoodRepository accRepo = new FoodRepository(); List <Food> accList = accRepo.SearchFood(text); this.FoodGridView.DataSource = accList; }
public ActionResult Dishlist() { FoodRepository FoodRepository = new FoodRepository(); List <Food> DishLists = FoodRepository.FoodList(); return(View(DishLists)); }
public IViewComponentResult Invoke(int id) { FoodRepository foodRepository = new FoodRepository(); var foodlist = foodRepository.List(x => x.CategoryId == id); //Gelen değere göre foodlistte tanımlamış olduğum değere listeyi getirecek return(View(foodlist)); }
public DataLayerService() { config = new LocalConfig(); pictureRepository = new PictureRepository(config); foodRepository = new FoodRepository(config); userRepository = new UserRepository(config); restaurantRepository = new RestaurantRepository(config); }
private void button2_Click(object sender, EventArgs e) { // this.panel1.Hide(); FoodRepository f = new FoodRepository(); this.dataGridView1.DataSource = f.GetAllFoods(); }
public UnitOfWork() { _context = new RestaurantContext(); Foods = new FoodRepository(_context); Extras = new ExtraRepository(_context); Specials = new SpecialRepository(_context); FoodPictures = new FoodPictureRepository(_context); }
private void AddProduct_Load(object sender, EventArgs e) { FoodRepository _DataAccess = new FoodRepository(); foreach (Food FCategory in _DataAccess.RetreiveAllCategoriesFromDatabase()) { ProductCategoryComboBox.Items.Add(FCategory.FCategory); } }
private void ViewSales_Load(object sender, EventArgs e) { FoodRepository _DataAccess = new FoodRepository(); foreach (Food SaleDetails in _DataAccess.RetreiveAllSales()) { SalesGridView.Rows.Add(SaleDetails.SaleID, SaleDetails.SaleTime, SaleDetails.FName, SaleDetails.Total, "View Products"); } }
public FoodController(FoodRepository repository, IStringLocalizerFactory factory, IHttpContextAccessor accessor, IWebQueryProvider queryProvider) : base(factory, accessor) { Repository = repository; this.queryProvider = queryProvider; }
public void FindAll_When_File_NotExists_Throws_Exception() { // Arrange var provider = new PhysicalFileProvider("c:\\"); var sut = new FoodRepository(provider.GetFileInfo("name.txt")); // Act, Assert Assert.Throws <FileNotFoundException>(() => sut.FindAll()); }
private void ViewSaleItems_Load(object sender, EventArgs e) { FoodRepository _DataAccess = new FoodRepository(); foreach (Food SaleItemsDetails in _DataAccess.RetreiveSaleItems(SaleID)) { SaleItemsGridView.Rows.Add(SaleItemsDetails.FName, SaleItemsDetails.FPrice, SaleItemsDetails.FQuantity, SaleItemsDetails.Total); } }
public UnitOfWork(ApplicationDbContext context) { _context = context; Recipes = new RecipeRepository(_context); RecipeIngredients = new RecipeIngredientRepository(_context); FoodTypes = new FoodTypeRepository(_context); Foods = new FoodRepository(_context); IngredientTypes = new IngredientTypeRepository(_context); Ingredients = new IngredientRepository(_context); UnitOfMeasures = new UnitOfMeasureRepository(_context); }
public void TestCreateFood() { using (var context = new FoodContext(ContextOptions)) { var repo = new FoodRepository(context); repo.CreateFood(new Food { Calories = 300, Carbohydrates = 34, Fats = 33, Name = "Chocolate", Protein = 5 }); repo.Dispose(); } }
private void ProductsGridView_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0) { if (ProductsGridView.Columns[e.ColumnIndex].Name == "DeleteProductColumn") { if (MessageBox.Show("Are You Sure You Want to Delete this Product\nfrom Database", "Warning", MessageBoxButtons.YesNo) == DialogResult.Yes) { int ProductID = Convert.ToInt32(ProductsGridView.Rows[e.RowIndex].Cells["ProductIDColumn"].Value); FoodRepository _DataAccess = new FoodRepository(); if (_DataAccess.DeleteProduct(ProductID)) { ProductsGridView.Rows.RemoveAt(e.RowIndex); } else if (!_DataAccess.DeleteProduct(ProductID)) { MessageBox.Show("Product Not Deleted"); } } } else if (ProductsGridView.Columns[e.ColumnIndex].Name == "EditProductColumn") { int ProductID = Convert.ToInt32(ProductsGridView.Rows[e.RowIndex].Cells["ProductIDColumn"].Value); string ProductName = ProductsGridView.Rows[e.RowIndex].Cells["ProductNameColumn"].Value.ToString(); decimal ProductPrice = Convert.ToDecimal(ProductsGridView.Rows[e.RowIndex].Cells["ProductPriceColumn"].Value.ToString()); string ProductCategory = ProductsGridView.Rows[e.RowIndex].Cells["ProductCategoryColumn"].Value.ToString(); string ProductDescription = ProductsGridView.Rows[e.RowIndex].Cells["ProductDescriptionColumn"].Value.ToString(); byte[] ProductPicture = (byte[])ProductsGridView.Rows[e.RowIndex].Cells["ProductImageColumn"].Value; UpdateProucts UpdateProductForm = new UpdateProucts(ProductID, ProductName, ProductPrice, ProductCategory, ProductDescription, ProductPicture); if (UpdateProductForm.ShowDialog() == DialogResult.OK) { FoodRepository _DataAccess = new FoodRepository(); Food UpdatedProductDetail = _DataAccess.RetreiveProductDetails(ProductID); ProductsGridView.Rows[e.RowIndex].Cells["ProductNameColumn"].Value = UpdatedProductDetail.FName; ProductsGridView.Rows[e.RowIndex].Cells["ProductPriceColumn"].Value = UpdatedProductDetail.FPrice; ProductsGridView.Rows[e.RowIndex].Cells["ProductCategoryColumn"].Value = UpdatedProductDetail.FCategory; ProductsGridView.Rows[e.RowIndex].Cells["ProductDescriptionColumn"].Value = UpdatedProductDetail.FDescription; ProductsGridView.Rows[e.RowIndex].Cells["ProductImageColumn"].Value = UpdatedProductDetail.FPicture; } } } }
public void Food_AddItem_CountShouldIncrease() { FoodRepository Repo = new FoodRepository(); Food item = new Food(6, "Waffles", "Breakfast", "Syrup", 5); Repo.AddMenuItemToList(item); int Expected = 1; int Actual = Repo.Count(); Assert.AreEqual(Expected, Actual); }
public void FoodRepository() { Mock<IDbSetFactory> factory = new Mock<IDbSetFactory>(); Mock<DbSet<Food>> dbSet = new Mock<DbSet<Food>>(); factory.Setup(m => m.CreateDbSet<Food>()).Returns(dbSet.Object); FoodRepository repo = new FoodRepository(factory.Object); var Food = new Food(); var sequence = new MockSequence(); dbSet.InSequence(sequence).Setup(e => e.Add(Food)); dbSet.InSequence(sequence).Setup(e => e.Find(Food.Id)); dbSet.InSequence(sequence).Setup(e => e.Find(Food.Id)); dbSet.InSequence(sequence).Setup(e => e.Find(Food.Id)); repo.Create(Food); repo.Get(Food.Id); repo.Update(Food); repo.Delete(Food.Id); }
public FoodController(FoodRepository foodRepository) { _foodRepository = foodRepository; }