public static Domain.ClientCollection GetClientsByPhysicianId(int physicianId) { Domain.ClientCollection result = new Domain.ClientCollection(); YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName); MongoCollection physicianClientCollection = server.Database.GetCollection <BsonDocument>("PhysicianClient"); MongoCursor physicianClientCursor = physicianClientCollection.FindAs <BsonDocument>(Query.EQ("PhysicianId", BsonValue.Create(physicianId))); List <BsonValue> clientIdList = new List <BsonValue>(); foreach (BsonDocument bsonDocument in physicianClientCursor) { clientIdList.Add(bsonDocument.GetValue("ClientId").AsInt32); } MongoCollection clientCollection = server.Database.GetCollection <BsonDocument>("Client"); MongoCursor clientCursor = clientCollection.FindAs <BsonDocument>(Query.In("ClientId", clientIdList)); foreach (BsonDocument bsonDocument in clientCursor) { YellowstonePathology.Business.Client.Model.Client client = new YellowstonePathology.Business.Client.Model.Client(); YellowstonePathology.Business.Mongo.BSONPropertyWriter.Write(bsonDocument, client); result.Add(client); } return(result); }
public static Domain.ClientCollection GetClientsByPhysicianId(int physicianId) { Domain.ClientCollection result = new Domain.ClientCollection(); YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName); MongoCollection physicianClientCollection = server.Database.GetCollection<BsonDocument>("PhysicianClient"); MongoCursor physicianClientCursor = physicianClientCollection.FindAs<BsonDocument>(Query.EQ("PhysicianId", BsonValue.Create(physicianId))); List<BsonValue> clientIdList = new List<BsonValue>(); foreach (BsonDocument bsonDocument in physicianClientCursor) { clientIdList.Add(bsonDocument.GetValue("ClientId").AsInt32); } MongoCollection clientCollection = server.Database.GetCollection<BsonDocument>("Client"); MongoCursor clientCursor = clientCollection.FindAs<BsonDocument>(Query.In("ClientId", clientIdList)); foreach (BsonDocument bsonDocument in clientCursor) { YellowstonePathology.Business.Client.Model.Client client = new YellowstonePathology.Business.Client.Model.Client(); YellowstonePathology.Business.Mongo.BSONPropertyWriter.Write(bsonDocument, client); result.Add(client); } return result; }
public static Domain.ClientCollection GetClientsByProviderId(string objectId) { Domain.ClientCollection result = new Domain.ClientCollection(); SqlCommand cmd = new SqlCommand(); cmd.CommandText = "select c.* " + "from tblClient c " + "join tblPhysicianClient pc on c.ClientId = pc.ClientId " + "where pc.ProviderId = @ObjectId order by ClientName "; cmd.Parameters.Add("@ObjectId", SqlDbType.VarChar).Value = objectId; cmd.CommandType = CommandType.Text; using (SqlConnection cn = new SqlConnection(YellowstonePathology.Business.BaseData.SqlConnectionString)) { cn.Open(); cmd.Connection = cn; using (SqlDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { YellowstonePathology.Business.Client.Model.Client client = new YellowstonePathology.Business.Client.Model.Client(); YellowstonePathology.Business.Persistence.SqlDataReaderPropertyWriter sqlDataReaderPropertyWriter = new Persistence.SqlDataReaderPropertyWriter(client, dr); sqlDataReaderPropertyWriter.WriteProperties(); result.Add(client); } } } return result; }