public bool DeleteUsersAwardRecord(int userId) { if (UserAndAwards.Any(n => n.UserId != userId)) return false; UserAndAwards userAndAwards = new UserAndAwards(userId); UserAndAwards.Remove(userAndAwards); StreamReader reader = new StreamReader(entitiesConnectionsInformationFile); StreamWriter writer = new StreamWriter(entitiesConnectionsInformationFile); string[] strFromFile = reader.ReadToEnd().Split('\n'); foreach (var s in strFromFile) { var element = s.Split(' '); if (element[0] == userId.ToString()) { continue; } writer.WriteLine(s); } reader.Close(); writer.Close(); return true; }
public bool AddUsersAwardRecord(int userId) { if (UserAndAwards.Any(n => n.UserId == userId)) return false; UserAndAwards userAndAwards = new UserAndAwards(userId); UserAndAwards.Add(userAndAwards); StreamWriter writer = new StreamWriter(entitiesConnectionsInformationFile); writer.WriteLine(userId); writer.Close(); return true; }