Managing User Data: Filtering and Aggregation in C#
Managing User Data: Filtering and Aggregation in C#
Welcome to today's lesson on applying data filtering and aggregation in a real-world scenario using a user management system. We'll start by building a foundational structure that can handle basic user operations. Then, we'll expand it by introducing more advanced functionalities that allow filtering and aggregating user data.
Starter Task Methods
In our starter task, we will implement a class that manages basic operations on a collection of user data, specifically handling adding new users, retrieving user profiles, and updating user profiles.
Here are the starter task methods:
addUser(string userId, int age, string country, bool subscribed)- adds a new user with the specified attributes. Returnstrueif the user was added successfully andfalseif a user with the sameuserIdalready exists.getUser(string userId)- returns the user's profile as an object if the user exists; otherwise, returnsnull.updateUser(string userId, int? age, string country, bool? subscribed)- updates the user's profile based onnon-nullparameters. Returnstrueif the user exists and was updated,falseotherwise.
Starter Task Implementation
The C# implementation of our starter task is shown below:
This implementation covers all our starter methods. Let's move forward and introduce more complex functionalities.
