Exemple #1
0
        public ForumView CreateForum(ForumForm value, UserIdentity identity)
        {
            var forum = new ForumObj
            {
                Id          = ObjectId.GenerateNewId().ToString(),
                Name        = value.Name,
                UrlPicture  = value.Image,
                Description = value.Description,
                Channels    = new List <Channel>(),
                Users       = new List <User>()
            };

            lock ( LockObject )
            {
                forum.Users.Add(new User
                {
                    Id         = identity.ID,
                    Pseudo     = identity.Pseudo,
                    UrlPicture = Config.URL + "/account/picture/" + identity.ID
                });

                this.Context.GetCollection().InsertOne(forum);
            }

            if (forum.Id != null)
            {
                return(this.GetForumById(forum.Id).ToViewForum());
            }

            return(forum.ToViewForum());
        }
Exemple #2
0
        public ForumPanelView GetForumPanel(string id, UserIdentity identity)
        {
            ForumObj forum = this.GetForumById(id);

            ForumPanelView panel = new ForumPanelView();

            if (forum == null)
            {
                return(panel);
            }

            panel.Forum    = forum.ToViewForum();
            panel.Channels = forum.Channels.Select(channel => channel.ToChannelView()).ToList();
            panel.Users    = forum.Users.Select(user => user.ToUserView()).ToList();

            return(panel);
        }