private static Location GetOrCreateLocation(string locationName, ChainOfSupermarketsContext db) { var location = db.Locations.FirstOrDefault(l => l.Name == locationName); if (location == null) { location = new Location { Name = locationName }; db.Locations.Add(location); db.SaveChanges(); } return location; }
private Location GetOrCreateLocation(string locationName) { var location = this.db.Locations.FirstOrDefault(l => l.Name == locationName); if (location == null) { location = new Location { Name = locationName }; this.db.Locations.Add(location); this.db.SaveChanges(); } return location; }