static void Main(string[] args)
        {
            IStregsystem          stregsystem = new Stregsystem();
            IStregsystemUI        ui          = new StregsystemCLI(stregsystem);
            StregsystemController sc          = new StregsystemController(ui, stregsystem);

            ui.Start();
        }
        public static List <Product> Deactivate(int productId)
        {
            StregsystemCLI CLI    = new StregsystemCLI();
            FileWriters    writer = new FileWriters();

            ReadFromCsv.ProductList.Where(x => x.Id == productId).ToList().ForEach(x => x.Active = false);
            writer.WriteToProductCsv("../../products.csv", ReadFromCsv.ProductList);
            CLI.DisplayAktiveProducts();
            return(null);
        }
Exemple #3
0
        static void Main(string[] args)
        {
            // In the start all files will be loaded and "database" lists will be pupulated
            File.WriteAllText(@"../../transactions.csv", string.Empty);
            ReadFromCsv    csvReader = new ReadFromCsv();
            StregsystemCLI ui        = new StregsystemCLI();

            csvReader.CreateUserList("../../users.csv");
            csvReader.CreateProductList("../../products.csv");
            csvReader.CreateTransactionList();
            //We will now start the interface
            ui.Start();
        }
Exemple #4
0
 static void Main(string[] args)
 {
     try {
         if (StregsystemLoader.Load())
         {
             IStregsystemUI ui = new StregsystemCLI();
             ui.Start();
         }
         else
         {
             throw new FileLoadException();
         }
     } catch (FileLoadException) {
         Console.WriteLine("Kunne ikke hente indhold.");
     }
 }
Exemple #5
0
        public StregsystemController(IStregsystemUI ui)
        {
            UI             = (StregsystemCLI)ui;
            _adminCommands = new Dictionary <string, Action <dynamic, dynamic> > {
                { "?", (x, y) => UI.DisplayHelp() },

                { ":q", (x, y) => UI.Close() },
                { ":quit", (x, y) => UI.Close() },
                {
                    ":activate",
                    (x, y) => {
                        Product.Find(int.Parse(x)).Activate();
                        UI.DisplayActivation(int.Parse(x), true);
                    }
                },
                {
                    ":deactivate",
                    (x, y) => {
                        Product.Find(int.Parse(x)).Deactivate();
                        UI.DisplayActivation(int.Parse(x), false);
                    }
                },
                {
                    ":crediton",
                    (x, y) => {
                        Product.Find(x).CanBeBoughtOnCredit = true;
                        UI.DisplayCreditChange(x, false);
                    }
                },
                {
                    ":creditoff",
                    (x, y) => {
                        Product.Find(x).CanBeBoughtOnCredit = false;
                        UI.DisplayCreditChange(x, false);
                    }
                },
                {
                    ":addcredits",
                    (x, y) => {
                        User u           = User.FindBy("Username", x);
                        var  transaction = new InsertCashTransaction(u, decimal.Parse(y));
                        transaction.Execute();
                        UI.DisplayAddedCreditsToUser(User.FindBy("Username", x), decimal.Parse(y));
                    }
                }
            };
        }