Ejemplo n.º 1
0
        //-----------------------
        public Person Create(string name, string phone, string city)
        {
            if (string.IsNullOrWhiteSpace(name) || string.IsNullOrWhiteSpace(city) || string.IsNullOrWhiteSpace(phone))
            {
                return(null);
            }
            Person person = new Person(name, phone, city);

            _context.Add(person);
            _context.SaveChanges();
            return(person);
        }
Ejemplo n.º 2
0
 public static void Init(PeopleDbContext context)
 {
     context.Database.EnsureCreated();
     if (context.Persons.Any())
     {
         return;
     }
     else
     {
         context.Persons.Add(new Person("Mattias", "Rävemåla", "0735-XXXXXX"));
         context.SaveChanges();
     }
 }