Exemplo n.º 1
0
        public ObjectRastreio GetObjectRastreioId(int idUser, int idObject)
        {
            ObjectRastreio objectRet = new ObjectRastreio();

            using (var context = new MyDbContext()){
                var objects  = context.ObjectRastreio;
                var objectsA = objects.Where(p => p.idUser == idUser && p.idObject == idObject).ToList();

                if (objectsA.Count > 0)
                {
                    objectRet = objectsA[0];

                    ObjectLocationDML objectLocationDML = new ObjectLocationDML();
                    objectRet.objectLocation = new List <ObjectLocation>();

                    var objectLocation = objectLocationDML.GetObjectLocationUltimo(idObject);
                    if (objectLocation.idObjectLocation > 0)
                    {
                        objectRet.objectLocation.Add(objectLocation);
                    }
                }
            }

            return(objectRet);
        }
Exemplo n.º 2
0
        public List <ObjectRastreio> GetObjectRastreio(int idUser)
        {
            List <ObjectRastreio> objectRet = new List <ObjectRastreio>();

            using (var context = new MyDbContext()){
                var objects = context.ObjectRastreio;
                objectRet = objects.Where(p => p.idUser == idUser).ToList();

                ObjectLocationDML objectLocationDML = new ObjectLocationDML();

                foreach (var obj in  objectRet)
                {
                    obj.objectLocation = new List <ObjectLocation>();
                    var objectLocation = objectLocationDML.GetObjectLocationUltimo(obj.idObject);
                    if (objectLocation.idObjectLocation > 0)
                    {
                        obj.objectLocation.Add(objectLocation);
                    }
                }
            }

            return(objectRet);
        }