Exemple #1
0
        public List <Product> RetrieveRelativeProducts(Productcategorie categorie, int aantal)
        {
            List <Product> all        = this.RetrieveAll();
            List <Product> returnList = all.OrderByDescending(p => p.Id).Take(aantal).ToList();

            return(returnList);
        }
 // GET: Productcategory/{id}
 public ActionResult ProductCategorie(string id)
 {
     if (id != null)
     {
         ViewBag.products   = DalWebshop.Models.Product.GetByCategorieId(Convert.ToInt32(id));
         ViewBag.categories = Productcategorie.All();
     }
     return(View("~/Views/Product/Index.cshtml"));
 }
        public void Create()
        {
            ProductcategorieSQLContext psc = new ProductcategorieSQLContext();
            ProductCategorieRepository pr  = new ProductCategorieRepository(psc);

            Productcategorie p = pr.Retrieve("1");

            //  p.Hoofdcategorie = pr.Retrieve("1");
            pr.Create(p);
        }
        public void Update()
        {
            ProductcategorieSQLContext psc = new ProductcategorieSQLContext();
            ProductCategorieRepository pr  = new ProductCategorieRepository(psc);

            Productcategorie p = pr.Retrieve("1");

            p.Omschrijving = "testaangepast";

            pr.Update(p);
        }
        // GET: Manage/Products
        public ActionResult Products(string id)
        {
            ViewBag.Producten   = Product.All();
            ViewBag.Leverancier = Leverancier.All();
            ViewBag.Categorien  = Productcategorie.All();

            if (id != null)
            {
                ViewBag.Product  = Product.Find(id);
                ViewBag.Discount = Korting.Find(id);
            }

            return(View("~/Views/Manage/Products.cshtml"));
        }
        public void Retrieve()
        {
            ProductcategorieSQLContext psc = new ProductcategorieSQLContext();
            ProductCategorieRepository pr  = new ProductCategorieRepository(psc);

            Productcategorie pc = pr.Retrieve("2");

            Assert.IsTrue(pc.Id == 2);
            Assert.IsTrue(pc.Hoofdcategorie.Id == 1);

            pc = pr.Retrieve("1");

            Assert.IsTrue(pc.Id == 1);
            Assert.IsTrue(pc.Hoofdcategorie == null);
        }
 public BestellingsProduct(int id, string naam, Menukaart kaart, Productcategorie categorie, double prijs, int aantalInVoorraad, string commentaar, int aantal)
     : base(id, naam, kaart, categorie, prijs, aantalInVoorraad)
 {
     this.Commentaar = commentaar;
     this.Aantal = aantal;
 }
        public static bool AanpassenProduct(Product product, string nieuweNaam, Productcategorie nieuweCategorie, double nieuwePrijs, int nieuweVoorraad)
        {
            SqlCommand command = new SqlCommand(@"UPDATE PRODUCT 
                                                  SET naam = @Naam, prijs = @Prijs, aantal_in_voorraad = @Aantal_in_voorraad, menu_categorie = @Menu_categorie
                                                  WHERE PRODUCT.ID = @Product_id");
            nieuweNaam = nieuweNaam.Replace(' ', '_');
            command.Parameters.AddWithValue("Naam", nieuweNaam);
            command.Parameters.AddWithValue("Menu_categorie", (int)nieuweCategorie);
            command.Parameters.AddWithValue("Prijs", String.Format(new CultureInfo("en-US"), "{0:0.00}", nieuwePrijs));
            command.Parameters.AddWithValue("Aantal_in_voorraad", nieuweVoorraad);
            command.Parameters.AddWithValue("Product_id", product.Id);

            if (DatabaseWriter(command) == 1)
            {
                Database.CloseConnection();
                return true;
            }
            Database.CloseConnection();
            return false;
        }
 public void Update(Productcategorie obj)
 {
     _crudInterface.Update(obj);
 }
 public string Create(Productcategorie obj)
 {
     return(_crudInterface.Create(obj));
 }