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.DemandCreate <Message>(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, MessageTarget.Create(discussion.ID), discussion.Project.Title, discussion.Title);

            return(MessageWrapperSelector(discussion));
        }
Esempio n. 2
0
        public ObjectWrapperBase CreateNewTag(string data)
        {
            if (string.IsNullOrEmpty(data))
            {
                throw new ArgumentException("data");
            }
            ProjectSecurity.DemandCreate <Project>(null);

            var result = EngineFactory.TagEngine.Create(data);

            return(new ObjectWrapperBase {
                Id = result.Key, Title = result.Value
            });
        }