Example #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);
        }
Example #2
0
        public ObjectRastreio Update(int idUser, int idObject, ObjectRastreio objectRastreio)
        {
            using (var context = new MyDbContext())
            {
                var userList = context.ObjectRastreio.Where(p => p.idUser == idUser && p.idObject == idObject).ToList()[0];
                userList.description = objectRastreio.description;

                context.SaveChanges();
            }


            return(GetObjectRastreioId(idUser, idObject));
        }
Example #3
0
        public ObjectRastreio GetObjectRastreioCode(string objectCode)
        {
            ObjectRastreio objectRet = new ObjectRastreio();

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

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

            return(objectRet);
        }
Example #4
0
        public ObjectRastreio GetObjectRastreioId2(int idObject)
        {
            ObjectRastreio objectRet = new ObjectRastreio();

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

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

            return(objectRet);
        }
Example #5
0
        public ObjectRastreio Insert(int idUser, ObjectRastreio objectRastreio)
        {
            using (var context = new MyDbContext())
            {
                context.Database.EnsureCreated();
                objectRastreio.idUser       = idUser;
                objectRastreio.status       = "A";
                objectRastreio.dateRegister = DateTime.Now;

                context.ObjectRastreio.Add(objectRastreio);

                context.SaveChanges();

                string body = "{ \"idObject\": " + objectRastreio.idObject + " }";
                Util   util = new Util();
                util.SendSQS(body);
            }


            return(GetObjectRastreioId(idUser, objectRastreio.idObject));
        }