コード例 #1
0
 public void EditTerminal(VMachine vMachine, string newLocation)
 {
     using (var context = new TerminalsDB())
     {
         var terminalFromDB = context.VMachines.Find(vMachine.Id);
         terminalFromDB.Location = newLocation;
         context.SaveChanges();
         VMChanged?.Invoke(terminalFromDB);
     }
 }
コード例 #2
0
        public void AddTerminal(string location)
        {
            using (var context = new TerminalsDB())
            {
                if (context.VMachines.Any(v => v.Location == location))
                {
                    throw new Exception("Vending machine with this location already exists!");
                }

                var vMachine = new VMachine {
                    Location = location
                };
                vMachine.Money = DataForTerminal.GetMoney();
                context.VMachines.Add(vMachine);
                context.SaveChanges();
                VMChanged?.Invoke(vMachine);
            }
        }