Example #1
0
        public void UpdateOrderInDB([FromBody] User value, string key)
        {
            var db            = new UserModelDataContext();
            int keyValueAsInt = Int32.Parse(key);
            var query         = from User in db.Users
                                where User.Id == keyValueAsInt
                                select User;

            var userInDB = query.First();

            #region changeDb
            if (userInDB.username != value.username)
            {
                userInDB.username = value.username;
            }
            if (userInDB.password != value.password)
            {
                userInDB.password = value.password;
            }
            if (userInDB.email != value.email)
            {
                userInDB.email = value.email;
            }
            if (userInDB.phone_number != value.phone_number)
            {
                userInDB.phone_number = value.phone_number;
            }
            #endregion

            db.SubmitChanges();
        }
Example #2
0
        public void WriteOrderToDB([FromBody] User value)
        {
            var db = new UserModelDataContext();

            db.Users.InsertOnSubmit(value);
            db.SubmitChanges();
        }
Example #3
0
        public User Get(string key = null)
        {
            var db = new UserModelDataContext();
            IEnumerable <User> queryResult;

            queryResult = db.Users.Where(o => o.username == key);
            var User = queryResult.FirstOrDefault();

            return(User);
        }
Example #4
0
        public List <User> GetAll()
        {
            var db = new UserModelDataContext();

            IEnumerable <User> queryResult;

            queryResult = db.Users.OrderBy(o => o.Id);

            return(queryResult.ToList <User>());
        }