public int Insert(ArticleReviewer item)
 {
     using (var conn = db.GetOpenConnection())
     {
         return conn.Execute("INSERT INTO ArticleReviewer(ArticleID, UserID, ReviewTemplateID) VALUES(@ArticleID, @UserID, @ReviewTemplateID)", new {
             ArticleID = item.ArticleID,
             UserID = item.Reviewer.UserID,
             ReviewTemplateID = item.Template.ReviewTemplateID
         });
     }
 }
 public void Update(ArticleReviewer item)
 {
     using (var conn = db.GetOpenConnection())
     {
         string sql = @"UPDATE [ArticleReviewer]
                         SET [ArticleID] = @ArticleID
                             ,[UserID] = @UserID
                             ,[ReviewStatusID] = @ReviewStatusID
                             ,[ReviewTemplateID] = @ReviewTemplateID
                             ,[Comments] = @Comments
                             ,[RejectReason] = @RejectReason
                         WHERE ArticleReviewerID = @ArticleReviewerID";
         var parameters = new DynamicParameters(item);
         conn.Execute(sql, parameters);
     }
 }
Esempio n. 3
0
        public CallResult AddReviewerToArticle(int articleId, int userId, int templateId)
        {
            try
            {
                bool alreadyAssigned = GetReviewsForArticle(articleId)
                    .Where(x => x.UserID == userId && x.ReviewTemplateID == templateId).Any();

                if (!alreadyAssigned)
                {
                    var item = new ArticleReviewer();
                    item.Reviewer.UserID = userId;
                    item.ArticleID = articleId;
                    item.Template.ReviewTemplateID = templateId;
                    articleReviewerRepository.Insert(item);
                    result.SetSuccess("Se asignó el revisor al artículo.");
                }
                else
                    result.SetWarning("Ya asignó el revisor al artículo con la plantilla seleccionada.");
               
            }
            catch(Exception e)
            {
                Logger.Log(e);
                result.SetError();
            }

            return result;
        }