public async Task <World> CreateStory(Guid worldId, string title)
        {
            // get the world that you want to add a story to
            var world = await _worldRepository.Get(worldId);

            if (world == null)
            {
                throw new WorldNotFoundException(worldId);
            }
            // new story that you create in the story collection
            var newstory = await _storyRepository.Create(new Story()
            {
                Id       = Guid.NewGuid(),
                Title    = title,
                Chapters = new Dictionary <string, List <int> >(),
                Pages    = new Dictionary <string, Page>()
            });

            // new world that you added storyref too
            world.Stories.Add(new StoryRef()
            {
                Id    = newstory.Id,
                Title = newstory.Title
            });
            //update db and return the world
            return(await _worldRepository.Update(world.Id, world));
        }
Beispiel #2
0
 public async Task Create(Story item)
 {
     item.TimePublicate = DateTime.Now;
     _storyRepository.Create(item);
     await _unitOfWork.SaveAsync();
 }