예제 #1
0
        public Person Create(string name, string city, string birthcity)
        {
            if (string.IsNullOrWhiteSpace(name) || string.IsNullOrWhiteSpace(city) || string.IsNullOrWhiteSpace(birthcity))
            {
                return(null);
            }
            Person person = new Person(name, city, birthcity);

            _context.Add(person);
            _context.SaveChanges();
            return(person);
        }
예제 #2
0
        public static void initialize(PeopleDBContext context)
        {
            context.Database.EnsureCreated();

            if (context.Poeples.Any())
            {
                return;
            }
            else
            {
                context.Poeples.Add(new Person("Mattias", "Rävemåla", "Malmö"));
                context.SaveChanges();
            }
        }