Exemplo n.º 1
0
        public object FindByID(string entityID)
        {
            GetCohortDataResponse cohortResponse = null;

            using (CohortMongoContext ctx = new CohortMongoContext(_dbName))
            {
                List <IMongoQuery> queries = new List <IMongoQuery>();
                queries.Add(Query.EQ(MECohort.IdProperty, ObjectId.Parse(entityID)));
                queries.Add(Query.EQ(MECohort.DeleteFlagProperty, false));
                IMongoQuery mQuery   = Query.And(queries);
                MECohort    meCohort = ctx.Cohorts.Collection.Find(mQuery).FirstOrDefault();
                if (meCohort != null)
                {
                    cohortResponse = new GetCohortDataResponse();
                    API.DataDomain.Cohort.DTO.CohortData cohort = new API.DataDomain.Cohort.DTO.CohortData {
                        ID              = meCohort.Id.ToString(),
                        SName           = meCohort.ShortName,
                        Query           = meCohort.Query,
                        QueryWithFilter = meCohort.QueryWithFilter,
                        Sort            = meCohort.Sort
                    };
                    cohortResponse.Cohort = cohort;
                }
            }
            return(cohortResponse);
        }
Exemplo n.º 2
0
        public IEnumerable <object> SelectAll()
        {
            IEnumerable <object> query = null;
            List <API.DataDomain.Cohort.DTO.CohortData> cohorts = null;

            using (CohortMongoContext ctx = new CohortMongoContext(_dbName))
            {
                List <MECohort> meCohorts = ctx.Cohorts.Collection.Find(Query.EQ(MECohort.DeleteFlagProperty, false)).ToList();
                if (meCohorts != null)
                {
                    cohorts = new List <API.DataDomain.Cohort.DTO.CohortData>();
                    foreach (MECohort m in meCohorts)
                    {
                        API.DataDomain.Cohort.DTO.CohortData cohort = new API.DataDomain.Cohort.DTO.CohortData {
                            ID = m.Id.ToString(), SName = m.ShortName, Query = m.Query, Sort = m.Sort
                        };
                        cohorts.Add(cohort);
                    }
                }
            }
            query = ((IEnumerable <object>)cohorts); //.AsEnumerable<object>();

            return(query);
        }