Пример #1
0
        public void AddAvenger(Avenger avenger)
        {
            // vizsgálat
            bool exist = false;

            if (avenger != null)
            {
                foreach (Avenger item in repo.GetAvengers())
                {
                    if (item.Name == avenger.Name)
                    {
                        exist = true;
                    }
                }

                if (!exist)
                {
                    repo.AddAvenger(avenger);
                }
                else
                {
                    throw new AvengerExistsException("This Avenger already exists in the database.");
                }
            }
            else
            {
                throw new NullReferenceException("Null reference was caused from AddAvenger.");
            }
        }
Пример #2
0
 public void AddAvenger(Avenger avenger)
 {
     db.Avenger.Add(avenger);
     db.SaveChanges();
 }