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);
        }
Exemple #2
0
        public IEnumerable <Jedi> GetJedis()
        {
            var bag = new Jedi[] { };

            try
            {
                Console.WriteLine("Accessing to the database to retrieve the information");
                bag = new[]
                {
                    new Jedi()
                    {
                        IntergalacticBoard = "123", Name = "Obi Wan", LightSaberColor = Color.SlateBlue
                    },
                    new Jedi()
                    {
                        IntergalacticBoard = "456", Name = "Rahm Kota", LightSaberColor = Color.SlateBlue
                    },
                    new Jedi()
                    {
                        IntergalacticBoard = "789", Name = "Shaak Ti", LightSaberColor = Color.LimeGreen
                    },
                    new Jedi()
                    {
                        IntergalacticBoard = "19034", Name = "Starkiller", LightSaberColor = Color.DarkBlue
                    }
                };
            }
            catch (Exception e)
            {
                _logger.LogError(e.Message);

                // Return the empty list but not null
                return(bag);
            }

            return(bag);
        }