Example #1
0
        private void AddActivityToList(Domain.UserActivity.UserActivity userActivity,
                                       SingleUserActivity singleUserActivity)
        {
            var activitiesList = userActivity.Activities.ToList();

            activitiesList.Add(singleUserActivity);
            userActivity.Activities = activitiesList;
        }
Example #2
0
        /// <summary>
        /// This method adds a single activity to a list of user's single activities with
        /// a given userID. If there is no record of user activity, then the new record is created
        /// in the database.
        /// </summary>
        /// <exception cref="DatabaseException">
        /// When the error occurs while working with the database. Provides the meaningful description of the error.
        /// </exception>
        public async Task AddSingleActivityAsync(ObjectId userID, SingleUserActivity singleUserActivity)
        {
            await database.Connect();

            var filter = new EqualityFilter <ObjectId>("userID", userID);

            Domain.UserActivity.UserActivity userActivity = (await database.Get(filter).ConfigureAwait(false))
                                                            .FirstOrDefault();

            if (userActivity == null)
            {
                await CreateUserActivityAsync(userID).ConfigureAwait(false);
            }

            userActivity = (await database.Get(filter).ConfigureAwait(false))
                           .FirstOrDefault();

            AddActivityToList(userActivity, singleUserActivity);

            await database.Update(userActivity, new[] { "Activities" });
        }
Example #3
0
        /// <summary>
        /// Updates the given properties of a userActivity in a mongo database.
        /// </summary>
        /// <param name="properties">
        /// The array of properties which must be updated.
        /// </param>
        public async Task UpdateActivityAsync(Domain.UserActivity.UserActivity userActivity, IEnumerable <string> properties)
        {
            await database.Connect().ConfigureAwait(false);

            await database.Update(userActivity, properties).ConfigureAwait(false);
        }