Example #1
0
        public static View.PhysicianClientView GetPhysicianClientView(int physicianId)
        {
            View.PhysicianClientView physicianClientView = new View.PhysicianClientView();

            YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName);
            MongoCollection physicianCollection = server.Database.GetCollection <BsonDocument>("Physician");
            BsonDocument    physicianDocument   = physicianCollection.FindOneAs <BsonDocument>(Query.EQ("PhysicianId", BsonValue.Create(physicianId)));

            YellowstonePathology.Business.Mongo.BSONPropertyWriter.Write(physicianDocument, physicianClientView);

            MongoCollection  physicianClientCollection = server.Database.GetCollection <BsonDocument>("PhysicianClient");
            MongoCursor      physicianClientCursor     = physicianClientCollection.FindAs <BsonDocument>(Query.EQ("PhysicianId", BsonValue.Create(physicianClientView.PhysicianId)));
            List <BsonValue> clientIdList = new List <BsonValue>();

            foreach (BsonDocument bsonDocument in physicianClientCursor)
            {
                clientIdList.Add(bsonDocument.GetValue("ClientId"));
            }

            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);
                physicianClientView.Clients.Add(client);
            }

            return(physicianClientView);
        }
        public static View.PhysicianClientView GetPhysicianClientView(int physicianId)
        {
            View.PhysicianClientView physicianClientView = new View.PhysicianClientView();

            YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName);
            MongoCollection physicianCollection = server.Database.GetCollection<BsonDocument>("Physician");
            BsonDocument physicianDocument = physicianCollection.FindOneAs<BsonDocument>(Query.EQ("PhysicianId", BsonValue.Create(physicianId)));
            YellowstonePathology.Business.Mongo.BSONPropertyWriter.Write(physicianDocument, physicianClientView);

            MongoCollection physicianClientCollection = server.Database.GetCollection<BsonDocument>("PhysicianClient");
            MongoCursor physicianClientCursor = physicianClientCollection.FindAs<BsonDocument>(Query.EQ("PhysicianId", BsonValue.Create(physicianClientView.PhysicianId)));
            List<BsonValue> clientIdList = new List<BsonValue>();
            foreach (BsonDocument bsonDocument in physicianClientCursor)
            {
                clientIdList.Add(bsonDocument.GetValue("ClientId"));
            }

            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);
                physicianClientView.Clients.Add(client);
            }

            return physicianClientView;
        }
        private static View.PhysicianClientView BuildPhysicianClientView(SqlCommand cmd)
        {
            View.PhysicianClientView result = new View.PhysicianClientView();
            using (SqlConnection cn = new SqlConnection(Properties.Settings.Default.ProductionConnectionString))
            {
                cn.Open();
                cmd.Connection = cn;
                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        YellowstonePathology.Business.Persistence.SqlDataReaderPropertyWriter sqlDataReaderPropertyWriter = new Persistence.SqlDataReaderPropertyWriter(result, dr);
                        sqlDataReaderPropertyWriter.WriteProperties();
                    }

                    dr.NextResult();

                    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.Clients.Add(client);
                    }
                }
            }
            return result;
        }
        public static View.PhysicianClientView GetPhysicianClientView(string physicianId)
        {
            View.PhysicianClientView result = new View.PhysicianClientView();
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = "select * from tblPhysician where ObjectId = @ObjectId;" +
                " select c.* from tblClient c join tblPhysicianClient pc on c.ClientId = pc.ClientId where pc.ProviderId = @ObjectId order by ClientName";
            cmd.CommandType = CommandType.Text;
            cmd.Parameters.Add("@ObjectId", SqlDbType.VarChar).Value = physicianId;
            using (SqlConnection cn = new SqlConnection(Properties.Settings.Default.ProductionConnectionString))
            {
                cn.Open();
                cmd.Connection = cn;
                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        YellowstonePathology.Business.Persistence.SqlDataReaderPropertyWriter sqlDataReaderPropertyWriter = new Persistence.SqlDataReaderPropertyWriter(result, dr);
                        sqlDataReaderPropertyWriter.WriteProperties();
                    }

                    dr.NextResult();

                    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.Clients.Add(client);
                    }
                }
            }
            return result;
        }