コード例 #1
0
        //Register a device on a user
        public bool MobileRegister(Mobileunit mobileunit)
        {
            //No love if these variables are no good
            if (mobileunit.DeviceID.Length == 0 ||
                mobileunit.Displayname.Length == 0 ||
                GetUsername(mobileunit.UserID).Length == 0)
            {
                return(false);
            }

            //Add database access
            LiteCollection <Mobileunit> aDBValues = m_db.GetCollection <Mobileunit>("mobile");

            //Set the time for adding
            mobileunit.Added = DateTime.Now;

            //Check if it exists already
            //Add new mobile to register if not
            if (IsMobileRegistered(mobileunit.DeviceID, mobileunit.UserID))
            {
                var results = aDBValues.FindOne(x => x.DeviceID == mobileunit.DeviceID);
                mobileunit.Id = results.Id;
                aDBValues.Update(mobileunit);
            }
            else
            {
                aDBValues.Insert(mobileunit);
            }

            return(true);
        }
コード例 #2
0
        public bool MobileRegister(string AppId, int UserID, string Displayname)
        {
            Mobileunit mobileunit = new Mobileunit
            {
                DeviceID    = AppId,
                UserID      = UserID,
                Displayname = Displayname,
            };

            return(MobileRegister(mobileunit));
        }