Exemple #1
0
        public bool Koop(string gebruikersnaam, string wachtwoord, int productid, int aantal)
        {
            // Alleen mogelijk met geldige credentials
            if (!Inloggen(gebruikersnaam, wachtwoord))
            {
                return(false);
            }

            if (aantal <= 0)
            {
                return(false);
            }

            var productPrijs = productDao.VerkrijgPrijs(productid);

            if (productPrijs == -1)
            {
                return(false);
            }

            if (aantal > productDao.VerkrijgAantal(productid))
            {
                return(false);
            }

            if (productPrijs * aantal > gebruikerDao.VerkrijgSaldo(gebruikersnaam))
            {
                return(false);
            }

            if (!productDao.VerkoopProduct(productid, aantal))
            {
                return(false);
            }

            if (!gebruikerDao.KoopProduct(gebruikersnaam, productid, aantal, productPrijs))
            {
                return(false);
            }

            return(true);
        }