Example #1
0
        public MessageWrapper AddProjectMessage(int projectid, string title, string content, string participants, bool?notify)
        {
            if (string.IsNullOrEmpty(title))
            {
                throw new ArgumentException(@"title can't be empty", "title");
            }
            if (string.IsNullOrEmpty(content))
            {
                throw new ArgumentException(@"description can't be empty", "content");
            }

            var project = EngineFactory.ProjectEngine.GetByID(projectid).NotFoundIfNull();

            ProjectSecurity.DemandCreateMessage(project);

            var messageEngine = EngineFactory.MessageEngine;
            var discussion    = new Message
            {
                Description = content,
                Title       = title,
                Project     = project,
            };

            messageEngine.SaveOrUpdate(discussion, notify.HasValue ? notify.Value : true, ToGuidList(participants));
            MessageService.Send(Request, MessageAction.DiscussionCreated, discussion.Project.Title, discussion.Title);

            return(new MessageWrapper(discussion));
        }
Example #2
0
        public MessageWrapper AddProjectMessage(int projectid, string title, string content, string participants, bool?notify)
        {
            if (string.IsNullOrEmpty(title))
            {
                throw new ArgumentException(@"title can't be empty", "title");
            }
            if (string.IsNullOrEmpty(content))
            {
                throw new ArgumentException(@"description can't be empty", "content");
            }

            var project = EngineFactory.GetProjectEngine().GetByID(projectid).NotFoundIfNull();

            ProjectSecurity.DemandCreateMessage(project);

            var newMessage = new Message
            {
                Content = content,
                Title   = title,
                Project = project,
            };

            EngineFactory.GetMessageEngine().SaveOrUpdate(newMessage, notify ?? true, ToGuidList(participants), null);
            return(new MessageWrapper(newMessage));
        }