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 ImportInSql(IClinicsData data, string name, decimal price, string information) { var exists = data.Procedures.All() .Where(p => p.Name.Equals(name)) .FirstOrDefault(); if (exists == null) { Procedure procedure = new Procedure { Id = Guid.NewGuid(), Name = name, Price = price, Information = information }; data.Procedures.Add(procedure); } }
private void InportInMongo(string name, decimal price, string information) { var procedures = mongoDb.GetCollection<BsonDocument>("Procedures"); var exists = procedures.FindAll().Where(p => p["Name"].Equals(name)).FirstOrDefault(); if (exists == null) { Procedure procedure = new Procedure { Id = Guid.NewGuid(), Name = name, Price = price, Information = information }; procedures.Insert<Procedure>(procedure); } }
private void ImportProcedures(IClinicsData data) { var allProcedures = mongoDb.GetCollection<BsonDocument>("Procedures").FindAll(); foreach (var procedure in allProcedures) { var idGuid = procedure["_id"].AsGuid; var name = this.GetValue(procedure, "Name"); var price = decimal.Parse(this.GetValue(procedure, "Price")); var information = this.GetValue(procedure, "Information"); var existingRecord = data.Procedures.All() .Where(p => p.Name.Equals(name)) .FirstOrDefault(); if (existingRecord == null) { Procedure newProcedure = new Procedure { Id = idGuid, Name = name, Price = price, Information = information }; data.Procedures.Add(newProcedure); } else { existingRecord.Name = name; existingRecord.Price = price; existingRecord.Information = information; } } }