コード例 #1
0
 public bool AcceptArticle(int articleId, int editorId)
 {
     try
     {
         var article = _repository.GetArticleById(articleId);
         article.Status         = "accepted";
         article.AcceptanceDate = DateTime.Now;
         var authors      = _repository.GetAuthorsFromArticleId(articleId);
         var presentation = new PresentationDTO()
         {
             PresenterId      = authors.First().AccountId,
             Title            = article.Topic,
             ArticleId        = article.ArticleId,
             SpecialSessionId = article.SpecialSessionId
         };
         _presentationRepository.AddPresentation(presentation);
         var presentationId = (int)_presentationRepository.GetLastPresentationId();
         article.PresentationId = presentationId;
         _repository.EditArticle(article);
         foreach (var author in authors)
         {
             var message = new MessageDTO()
             {
                 SenderId   = editorId,
                 ReceiverId = author.AccountId,
                 Date       = DateTime.Now,
                 Content    = $"Your article {article.Topic} has been accepted"
             };
             if (message.SenderId != message.ReceiverId)
             {
                 _messageRepository.AddMessage(message);
             }
         }
     }
     catch
     {
         return(false);
     }
     return(true);
 }