public GetAllActionsDataResponse SelectAll(double versionNumber, Status status) { GetAllActionsDataResponse response = new GetAllActionsDataResponse() { Version = versionNumber }; List <DTO.ActionData> list = new List <DTO.ActionData>(); using (ActionMongoContext ctx = new ActionMongoContext(_dbName)) { //var x = (from a in ctx.Actions // //where a.CompletedBy.ToString().Length > 5 // select new DTO.ActionData // { // ID = a.Id.ToString(), // Name = a.Name, // Description = a.Description // //Status = status.ToString() // }); var l = from a in ctx.Actions select a; //foreach (ActionData act in x) //{ // if(act.CompletedBy.ToString().Length > 5) // response.Actions.Add(act); //} } return(response); }
public object FindByID(string entityID) { GetActionDataResponse actionResponse = null; using (ActionMongoContext ctx = new ActionMongoContext(_dbName)) { List <IMongoQuery> queries = new List <IMongoQuery>(); queries.Add(Query.EQ(MEAction.IdProperty, ObjectId.Parse(entityID))); queries.Add(Query.EQ(MEAction.DeleteFlagProperty, false)); IMongoQuery mQuery = Query.And(queries); MEAction meAction = ctx.Actions.Collection.Find(mQuery).FirstOrDefault(); if (meAction != null) { actionResponse = new GetActionDataResponse(); List <string> objectiveIDs = new List <string>(); if (meAction.Objectives != null) { foreach (Objective oi in meAction.Objectives) { objectiveIDs.Add(oi.Id.ToString()); } } API.DataDomain.Action.DTO.ActionData action = new API.DataDomain.Action.DTO.ActionData { ID = meAction.Id.ToString(), Name = meAction.Name, Description = meAction.Description, CompletedBy = meAction.CompletedBy.ToString(), Objectives = objectiveIDs, Status = toFriendlyString(meAction.Status) }; actionResponse.Action = action; } } return(actionResponse); }