Example #1
0
        public IEnumerable <Sith> GetSiths()
        {
            var bag = new Sith[] { };

            try
            {
                Console.WriteLine("Accessing to the database to retrieve the information");
                bag = new[]
                {
                    new Sith()
                    {
                        IntergalacticBoard = "101112", Name = "Darth Vader", LightSaberColor = Color.Red, DeathStarPass = "******"
                    },
                    new Sith()
                    {
                        IntergalacticBoard = "111113", Name = "El emperador Palpatin", LightSaberColor = Color.Red, DeathStarPass = "******"
                    },
                    new Sith()
                    {
                        IntergalacticBoard = "101114", Name = "Kylo Ren", LightSaberColor = Color.Red, DeathStarPass = "******"
                    }
                };
            }
            catch (Exception e)
            {
                _logger.LogError(e.Message);

                // Return the empty list but not null
                return(bag);
            }
            return(bag);
        }
        public void AddCombat(Jedi jedi, Sith sith)
        {
            if (jedi == null)
            {
                throw new ArgumentNullException(nameof(jedi));
            }
            if (sith == null)
            {
                throw new ArgumentNullException(nameof(sith));
            }

            if (Combats == null)
            {
                Combats = new ObservableCollection <Combat>();
            }

            var newCombat = new Combat(jedi, sith);

            _storage.CreateCombat(newCombat);
            _storage.SaveChanges();

            Combats.Add(newCombat);
        }