Example #1
0
        public bool DeleteByUserId(IConnectionHandler connectionHandler, Guid userId)
        {
            var articleFlowBo = new ArticleFlowBO();
            var articleFlows  = articleFlowBo.Where(connectionHandler, x => x.SenderId == userId || x.ReceiverId == userId);

            foreach (var articleFlow in articleFlows)
            {
                articleFlowBo.Delete(connectionHandler, articleFlow);
            }
            var list = this.Where(connectionHandler, x => x.UserId == userId);

            foreach (var securityUser in list)
            {
                base.Delete(connectionHandler, securityUser);
            }

            return(true);
        }
Example #2
0
        public bool AnswerArticle(IConnectionHandler connectionHandler, IConnectionHandler filemanagerconnection, Guid congressId,
                                  RefereeCartable refereeCartable, Guid answeredrefreeId, string comments,
                                  HttpPostedFileBase attachment)
        {
            var articleBo     = new ArticleBO();
            var articleFlowBo = new ArticleFlowBO();
            var config        = new ConfigurationBO().ValidConfig(connectionHandler, congressId);
            var refree        = new RefereeBO().Get(connectionHandler, answeredrefreeId);


            if (!this.ModifyCartabl(connectionHandler, refereeCartable.ArticleId, answeredrefreeId,
                                    refereeCartable.Status, refereeCartable.Visited, false))
            {
                return(false);
            }

            var article = articleBo.Get(connectionHandler, refereeCartable.ArticleId);

            article.FinalState = (byte)Enums.FinalState.WaitForAnswer;
            if (config.SentArticleSpecialReferee)
            {
                article.Status = refree.IsSpecial
                    ? (byte)Enums.ArticleState.WaitForScientificTeacher
                    : (byte)Enums.ArticleState.WaitforSpecialRefereeOpinion;
            }
            else
            {
                article.Status = (byte)Enums.ArticleState.WaitForScientificTeacher;
            }

            if (!articleBo.Update(connectionHandler, article))
            {
                throw new Exception(string.Format(Resources.Congress.ErrorInEditArticleCongress, Extention.GetAtricleTitle(article.CongressId)));
            }

            var lastSenderId = new ArticleFlowBO().SelectFirstOrDefault(connectionHandler, x => x.SenderId,
                                                                        x => x.ReceiverId == answeredrefreeId && x.ArticleId == article.Id,
                                                                        new OrderByModel <ArticleFlow>()
            {
                Expression = x => x.SaveDate + "" + x.SaveTime,
                OrderType  = OrderType.DESC
            });


            var lastrefree = new RefereeBO().Get(connectionHandler, lastSenderId);

            if (lastrefree != null && lastrefree.IsSpecial)
            {
                var lastrefereeCartable = new RefereeCartable();
                lastrefereeCartable = this.FirstOrDefaultWithOrderByDescending(connectionHandler, x => x.InsertDate,
                                                                               x => x.ArticleId == article.Id && x.RefereeId == lastrefree.Id);

                if (lastrefereeCartable != null)
                {
                    if (!this.ModifyCartabl(connectionHandler, lastrefereeCartable.ArticleId, lastSenderId,
                                            (byte)Enums.FinalState.RefereeAnswered, lastrefereeCartable.Visited, false))
                    {
                        return(false);
                    }
                }
                else
                {
                    if (!this.ModifyCartabl(connectionHandler, article.Id, lastSenderId, (byte)Enums.FinalState.WaitForAnswer, false, true))
                    {
                        return(false);
                    }
                }

                if (!articleFlowBo.AddFlow(connectionHandler, filemanagerconnection, answeredrefreeId, lastSenderId != Guid.Empty ? lastSenderId : (Guid?)null, refereeCartable.ArticleId,
                                           refereeCartable.Status, comments, attachment))
                {
                    return(false);
                }
            }
            else
            {
                var articleFlow =
                    articleFlowBo.FirstOrDefaultWithOrderBy(connectionHandler, x => x.SaveDate + " " + x.SaveTime,
                                                            x => x.ArticleId == refereeCartable.ArticleId && x.ReceiverId == answeredrefreeId);
                var senderId = articleFlow != null ? articleFlow.SenderId : (Guid?)null;
                if (!articleFlowBo.AddFlow(connectionHandler, filemanagerconnection, answeredrefreeId, senderId,
                                           refereeCartable.ArticleId, refereeCartable.Status, comments, attachment))
                {
                    return(false);
                }
            }

            return(true);
        }