Exemplo n.º 1
0
        public ICollection <StoryListItemForCategory> ConvertStoryBaseModeltoListItem(ICollection <Story> stories)
        {
            var listOfItems = new List <StoryListItemForCategory>();

            foreach (Story story in stories)
            {
                var listItem = new StoryListItemForCategory();
                listItem.Id              = story.Id;
                listItem.WriterName      = (_context.Writers.Single(w => w.Id == story.WriterId)).Name;
                listItem.Title           = story.Title;
                listItem.Location        = story.Location;
                listItem.DateTimeDisplay = StoryService.DisplayDateTime(story.TimeOfPublication);
                listOfItems.Add(listItem);
            }
            return(listOfItems);
        }
Exemplo n.º 2
0
        public ICollection <StoryListItemForWriter> ConvertStoryToListItemForWriter(ICollection <Story> stories)
        {
            var listOfItems = new List <StoryListItemForWriter>();

            foreach (Story story in stories)
            {
                var listItem = new StoryListItemForWriter();
                listItem.Id              = story.Id;
                listItem.Title           = story.Title;
                listItem.Location        = story.Location;
                listItem.DateTimeDisplay = StoryService.DisplayDateTime(story.TimeOfPublication);
                listItem.CategoryName    = (_context.Categories.Single(c => c.Id == story.CategoryId)).Name;

                listOfItems.Add(listItem);
            }
            return(listOfItems);
        }