Example #1
0
        /// <summary>
        /// Adds new product to DataBase.
        /// </summary>
        private static void AddNewProduct()
        {
            int    id;
            string name;
            double price;

            Console.WriteLine("Input id of product");
            id = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Input name of product");
            name = Console.ReadLine();
            Console.WriteLine("Input price of product");
            price = Convert.ToDouble(Console.ReadLine());
            Product  product = new Product(id, name, price);
            DataBase db      = DataBase.GetInstance();

            db.Add(product);
        }
Example #2
0
        /// <summary>
        /// Method adds new user to database
        /// </summary>
        /// <param name="newName">new user's name</param>
        /// <param name="newPassword">new user's password</param>
        /// <param name="rolesIdes">List of Ides of user's roles</param>
        /// <returns></returns>
        public static bool AddNewUser(string newName, string newPassword, List <int> rolesIdes)
        {
            if (CheckNameExistence(newName) == true)
            {
                return(false);
            }

            DataBase db = DataBase.GetInstance();

            db.SetConnections(Constants.PATH);
            db.LoadUsers();

            db.Add(new User(db.Users.Last().Id + 1, newName, newPassword, rolesIdes));
            db.CommitUsers();

            return(true);
        }