コード例 #1
0
        public bool ListWearables(ref string errorMessage, ref List <COP.API.Models.Wearable> results)
        {
            bool retVal = true;

            try
            {
                using (COPDBContext.monica_cnetContext context = new COPDBContext.monica_cnetContext())
                {
                    foreach (var loc in context.PersonThings)
                    {
                        COP.API.Models.Wearable z = new Models.Wearable();
                        z.PersonId  = loc.Personid;
                        z.ThingId   = (int?)loc.Thingid;
                        z.Timestamp = loc.Timepoint;
                        results.Add(z);
                    }



                    //Insert role connection;
                }
                return(retVal);
            }
            catch (Exception e)
            {
                errorMessage = "Database Excaption:" + e.Message + " " + e.StackTrace;
                return(false);
            }
        }
コード例 #2
0
        public bool WearablesPersonIdGet(string wbid, ref string errorMessage, ref List <COP.API.Models.Wearable> results)
        {
            bool retVal = true;

            try
            {
                using (COPDBContext.monica_cnetContext context = new COPDBContext.monica_cnetContext())
                {
                    //Make query
                    var pp = (from d in context.Thing
                              where d.Ogcid == wbid
                              select d);

                    if (pp == null || pp.Count() == 0)
                    {
                        errorMessage = "Non existing wearable:" + wbid;
                        retVal       = false;
                    }
                    else
                    {
                        results = new List <Models.Wearable>();
                        foreach (var p in pp)
                        {
                            var wearable = (from a in context.Thing
                                            join h in context.PersonThings
                                            on a.Thingid equals h.Thingid
                                            where a.Thingid == p.Thingid
                                            select h);
                            foreach (var obs in wearable)
                            {
                                COP.API.Models.Wearable wb = new Models.Wearable();
                                wb.PersonId  = obs.Personid;
                                wb.ThingId   = (int)obs.Thingid;
                                wb.Timestamp = obs.Timepoint;

                                results.Add(wb);
                            }
                        }
                    }



                    //Insert role connection;
                }
                return(retVal);
            }
            catch (Exception e)
            {
                errorMessage = "Database Excaption:" + e.Message + " " + e.StackTrace;
                return(false);
            }
        }