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(); }
public void WriteOrderToDB([FromBody] User value) { var db = new UserModelDataContext(); db.Users.InsertOnSubmit(value); db.SubmitChanges(); }
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); }
public List <User> GetAll() { var db = new UserModelDataContext(); IEnumerable <User> queryResult; queryResult = db.Users.OrderBy(o => o.Id); return(queryResult.ToList <User>()); }