//ToDo: Move this class elsewhere. public static Friend GetFriendFromUser(user user) { var friend = new Friend { Alias = user.alias, EmailAddress = user.email }; if (user.creation_time != null) { friend.CreationTime = (DateTime)user.creation_time; } if (user.skill_level != null) { friend.Level = (int)user.skill_level; } if (user.ranking != null) { friend.Ranking = (int)user.ranking; } if (user.experience != null) { friend.Experience = (long)user.experience; } return friend; }
private void RemovePendingFriendRequests(user user) { using (var connection = new SqlConnection(ConnectionString)) { using (var db = new OzwegoDataClassesDataContext(connection)) { var frdReqQuery = from frdReq in db.friendRequests where (frdReq.from_user == user.ID || frdReq.to_user == user.ID) select frdReq; foreach (var frdReq in frdReqQuery) { db.friendRequests.DeleteOnSubmit(frdReq); } try { db.SubmitChanges(); } catch (Exception e) { Trace.WriteLine(string.Format( "Exception in Database.RemovePendingFriendRequests!\n Exception: {0} \n Callstack: {1}", e.Message, e.StackTrace)); } } } }
public List<user_game> GetUserGameHistory(user user) { using (var connection = new SqlConnection(ConnectionString)) { using (var db = new OzwegoDataClassesDataContext(connection)) { var userQuery = from g in db.user_games where g.userID == user.ID select g; return userQuery.ToList(); } } }
public void AddNewUser(string newEmail, string newAlias) { if (string.IsNullOrEmpty(newEmail)) { return; } if (string.IsNullOrEmpty(newAlias)) { return; } using (var connection = new SqlConnection(ConnectionString)) { using (var db = new OzwegoDataClassesDataContext(connection)) { var newUser = new user { email = newEmail, alias = newAlias, creation_time = DateTime.UtcNow, last_seen_time = DateTime.UtcNow }; db.users.InsertOnSubmit(newUser); try { db.SubmitChanges(); } catch (Exception e) { Trace.WriteLine(string.Format( "Exception in Database.AddNewUser!\n Exception: {0} \n Callstack: {1}", e.Message, e.StackTrace)); } } } }
partial void Deleteuser(user instance);
partial void Updateuser(user instance);
partial void Insertuser(user instance);