Beispiel #1
0
 public void NewNodeRecord(EditNodeRecordModel model)
 {
     if (!model.FormData.SelectedNodeId.HasValue)
         throw new ArgumentException("model.FormData.SelectedNodeId不能为空");
     var nodeRecord = new NodeRecord();
     FillNodeRecord(nodeRecord, model.FormData);
     nodeRecord.RecordDescription.CreateBy(NpcContext.CurrentUser);
     _nodeRecordRepository.Save(nodeRecord);
 }
Beispiel #2
0
 public void FillFormData(EditNodeRecordModelFormData formData, NodeRecord nodeRecord)
 {
     formData.SelectedNodeId = nodeRecord.BelongsToNode.Id;
     formData.FirstImage = nodeRecord.FirstImage;
     formData.FirstTitle = nodeRecord.FirstTitle;
     formData.FirstContent = nodeRecord.FirstContent;
     formData.SecondTitle = nodeRecord.SecondTitle;
     formData.SecondImage = nodeRecord.SecondImage;
     formData.SecondContent = nodeRecord.SecondContent;
     formData.OrderSort = nodeRecord.OrderSort;
     formData.RecordLink = nodeRecord.RecordLink;
 }
Beispiel #3
0
 private NodeRecord FillSingleRecord(Guid unitId, string code, bool isPic)
 {
     var node = _nodeRepository.GetSingleByCode(unitId, code);
     if (node == null)
         return null;
     if (!node.OuterCategoryId.HasValue)
         return null;
     var article = isPic
                       ? _articleRepository.GetTopNPic(unitId, node.OuterCategoryId.Value, 1).FirstOrDefault()
                       : _articleRepository.GetTopN(unitId, node.OuterCategoryId.Value, 1).FirstOrDefault();
     if (article != null)
     {
         var nodeRecord = new NodeRecord();
         nodeRecord.FirstTitle = article.Title;
         nodeRecord.RecordLink = "/Home/Detail?Id=" + article.Id;
         nodeRecord.FirstContent = MyString.RemoveSpaceString(MyString.RemoveHtml(article.Content));
         nodeRecord.FirstImage = ApplicationConst.ImagePath + article.UrlOfCoverImage;
         nodeRecord.RecordDescription.DateOfCreate = article.RecordDescription.DateOfCreate;
         return nodeRecord;
     }
     return null;
 }
Beispiel #4
0
        private void FillRecords(ICollection<NodeRecord> nodeRecords, Guid unitId, int picTopN, int normalTopN,
                                 string code)
        {
            var node = _nodeRepository.GetSingleByCode(unitId, code);
            if (node == null)
                return;
            if (!node.OuterCategoryId.HasValue)
                return;
            if (nodeRecords.Count >= picTopN + normalTopN)
                return;
            var needPicN = picTopN - nodeRecords.Count;
            if (needPicN < 0)
                needPicN = 0;
            var needNormalN = normalTopN - (nodeRecords.Count - picTopN);
            if (needNormalN < 0)
                needNormalN = 0;

            if (needNormalN <= 0) return;

            var articles =
                _articleRepository.GetTopNWithPic(unitId, node.OuterCategoryId.Value, needPicN, needNormalN).ToList();
            foreach (var article in articles)
            {
                var record = new NodeRecord()
                {
                    FirstTitle = article.Title,
                    RecordLink = "/Home/Detail?Id=" + article.Id,
                    FirstContent = MyString.RemoveSpaceString(MyString.RemoveHtml(article.Content)),
                    FirstImage = article.UrlOfCoverImage
                };
                record.RecordDescription.DateOfCreate = article.RecordDescription.DateOfCreate;
                nodeRecords.Add(record);
            }
        }
Beispiel #5
0
 private void FillNodeRecord(NodeRecord nodeRecord, EditNodeRecordModelFormData formData)
 {
     nodeRecord.BelongsToNode = _nodeRepository.Find(formData.SelectedNodeId.Value);
     nodeRecord.FirstTitle = formData.FirstTitle;
     nodeRecord.FirstContent = formData.FirstContent;
     nodeRecord.SecondTitle = formData.SecondTitle;
     nodeRecord.SecondContent = formData.SecondContent;
     nodeRecord.RecordDescription.UserOfLasetestModify = NpcContext.CurrentUser;
     nodeRecord.RecordLink = formData.RecordLink;
     nodeRecord.IsShow = formData.IsShow;
     nodeRecord.OrderSort = formData.OrderSort;
     if (!string.IsNullOrEmpty(formData.FirstImage))
         nodeRecord.FirstImage = formData.FirstImage;
     if (!string.IsNullOrEmpty(formData.SecondImage))
         nodeRecord.SecondImage = formData.SecondImage;
 }