private static void SeedDatabase(ClinicsDB db) { var proc1 = new Procedure() { Name = "Blood test", Price = 50.00m }; var proc2 = new Procedure() { Name = "MRI", Price = 1000.00m }; var specialty = new Specialty() { Name = "Internist" }; var specialist = new Specialist() { FirstName = "Gregory", LastName = "House", SpecialtyId = specialty.Id }; var manip = new Manipulation() { Date = DateTime.Now, SpecialistId = specialist.Id }; manip.Procedures.Add(proc1); manip.Procedures.Add(proc2); db.Procedures.Add(proc1); db.Procedures.Add(proc2); db.Specialties.Add(specialty); db.Specialists.Add(specialist); db.Manipulations.Add(manip); SaveChanges(db); }
private void ImportSpecialties(IClinicsData data) { var allSpecialties = mongoDb.GetCollection<BsonDocument>("Specialties").FindAll(); foreach (var specialty in allSpecialties) { var id = this.GetValue(specialty, "SpecialtyId"); var idGuid = new Guid(id); var specialtyName = this.GetValue(specialty, "Specialty"); var existingRecord = data.Specialties.All() .Where(s => s.Id.Equals(idGuid)) .FirstOrDefault(); if (existingRecord == null) { Specialty newSpecialty = new Specialty { Id = idGuid, Speciality = specialtyName }; data.Specialties.Add(newSpecialty); } else { existingRecord.Speciality = specialtyName; } } }