Exemple #1
0
        public async Task update_post_like_count(string post_id, string emo, int value)
        {
            dataContext = new DataContext();
            var post_collection = dataContext.getConnection().GetCollection <Post>("Post");
            var filter          = Builders <Post> .Filter.Where(x => x._id == post_id);

            PostManagement pm     = new PostManagement();
            Post           p      = pm.getPost(post_id);
            var            update = Builders <Post> .Update.Set(emo, getEmojiCount(p, emo) + value);

            await post_collection.FindOneAndUpdateAsync(filter, update);
        }
        public async Task send_email_to_participant_post_comment(string post_id, Owner user, int activity)
        {
            var post_participant_collection = dataContext.getConnection().GetCollection <PostParticipant>("Post_Participant");
            var record = post_participant_collection.AsQueryable().Where(p => p._id == post_id).
                         SelectMany(c => c.participants).Where(p => p._id != user._id).Where(p2 => p2.status == true).ToArray();
            Post   post = pm.getPost(post_id);
            string link = "/Users/Profile/" + helper.EncodeTo64(post.owner._id) + "?p_ref=" + helper.EncodeTo64(post_id);

            foreach (Participant p in record)
            {
                mm.sendEmail(p.email, user.user_name, user.user_name + " commented about the post" + "<br/>" +
                             "<a href='" + link + "'>Click here to see</a>");
                await nm.insert_notification_recordAsync(p._id, new Notification
                {
                    _id         = ObjectId.GenerateNewId().ToString(),
                    time_sent   = DateTime.Now,
                    sender_id   = user._id,
                    description = "comment about the post",
                    activity    = activity,
                    url         = link
                });
            }
        }