public int CompareTo(object obj)
        {
            var processor = obj as ICallerIdDeviceProcessor;

            if (processor != null)
            {
                return(LinesCount.CompareTo(processor.LinesCount));
            }
            return(1);
        }
Exemple #2
0
        public Material SeedMaterial(Category category, string title, int commentsCount, string firstLine,
                                     string lineElement, LinesCount linesCount)
        {
            var publishDate       = dataContainer.IterateCommentPublishDate();
            int linesCountCurrent = ran.Next(linesCount.Min, linesCount.Max);

            int id = dataContainer.NextMaterialId();

            Material material = new Material
            {
                Id           = id,
                Title        = title,
                Text         = MakeSeedText(lineElement, 8, linesCountCurrent, firstLine),
                AuthorId     = dataContainer.GetRandomUserId(),
                CategoryId   = category.Id,
                PublishDate  = publishDate,
                LastActivity = publishDate,
                SortNumber   = id
            };

            var(preview, description) = MaterialExtensions.MakePreviewAndDescription(material.Text,
                                                                                     MaterialDescriptionLength,
                                                                                     MaterialPreviewLength);

            material.Preview = preview;

            SectionType sectionType = category.GetSectionType();

            if (sectionType != null && sectionType.Name == SectionTypeNames.Articles)
            {
                material.Description = "Описание материала: " + material.Title;
            }
            else
            {
                material.Description = description;
            }


            if (commentsCount > 0)
            {
                IList <Comment> comments = MakeComments(material, commentsCount);

                //Comment last = comments.OrderByDescending(x=>x.PublishDate).First();
                //material.SetLastComment(last);

                material.LastActivity  = comments.OrderByDescending(x => x.PublishDate).First().PublishDate;
                material.CommentsCount = comments.Count;

                dataContainer.Comments.AddRange(comments);
            }

            dataContainer.Materials.Add(material);

            return(material);
        }
Exemple #3
0
        public Material SeedMaterial(
            Category category,
            string title,
            int commentsCount,
            string firstLine,
            string lineElement, LinesCount linesCount)
        {
            var publishDate       = dataContainer.IterateCommentPublishDate();
            int linesCountCurrent = ran.Next(linesCount.Min, linesCount.Max);

            int id = dataContainer.NextMaterialId();

            Material material = new Material
            {
                Id           = id,
                Title        = title,
                Text         = MakeSeedText(lineElement, 8, linesCountCurrent, firstLine),
                AuthorId     = dataContainer.GetRandomUserId(),
                CategoryId   = category.Id,
                PublishDate  = publishDate,
                LastActivity = publishDate,
                SortNumber   = id
            };

            switch (category.MaterialsSubTitleInputType)
            {
            case MaterialsSubTitleInputType.Manual:
                material.SubTitle = "Описание материала: " + material.Title;
                break;

            case MaterialsSubTitleInputType.Auto:
                material.SubTitle = MakeSubTitle.Do(new HtmlParser().Parse(material.Text),
                                                    MaterialSubTitleLength);
                break;
            }


            if (commentsCount > 0)
            {
                IList <Comment> comments = MakeComments(material, commentsCount);

                //Comment last = comments.OrderByDescending(x=>x.PublishDate).First();
                //material.SetLastComment(last);

                material.LastActivity  = comments.OrderByDescending(x => x.PublishDate).First().PublishDate;
                material.CommentsCount = comments.Count;

                dataContainer.Comments.AddRange(comments);
            }

            dataContainer.Materials.Add(material);

            return(material);
        }
Exemple #4
0
 /* c_lines [int]
  * changes console's size (in lines)
  */
 void c_lines(IList <string> args)
 {
     if (args.Count == 1)
     {
         WriteLine(LinesCount.ToString());
     }
     else
     {
         LinesCount = int.Parse(args[1]);
     }
 }
        public Material SeedMaterial(
            Category category,
            string title,
            int commentsCount,
            string firstLine,
            string lineElement, LinesCount linesCount)
        {
            var publishDate       = dataContainer.IterateCommentPublishDate();
            int linesCountCurrent = ran.Next(linesCount.Min, linesCount.Max);

            int id = dataContainer.NextMaterialId();

            Material material = new Material
            {
                Id           = id,
                Title        = title,
                Text         = MakeSeedText(lineElement, 8, linesCountCurrent, firstLine),
                AuthorId     = dataContainer.GetRandomUserId(),
                CategoryId   = category.Id,
                PublishDate  = publishDate,
                LastActivity = publishDate,
                SortNumber   = id
            };

            if (commentsCount > 0)
            {
                var comments = MakeComments(material, commentsCount);

                material.LastActivity  = comments.OrderByDescending(x => x.PublishDate).First().PublishDate;
                material.CommentsCount = comments.Count;

                dataContainer.Comments.AddRange(comments);
            }

            dataContainer.Materials.Add(material);

            return(material);
        }
Exemple #6
0
 public int CompareTo(object obj)
 {
     return(obj is ICallerIdDeviceProcessor processor?LinesCount.CompareTo(processor.LinesCount) : 1);
 }
Exemple #7
0
        public int CompareTo(object obj)
        {
            var processor = obj as ICallerIdDeviceProcessor;

            return(processor != null?LinesCount.CompareTo(processor.LinesCount) : 1);
        }