Ejemplo n.º 1
0
        public void Execute(StoryJournalistDto request)
        {
            var storyJournalist = this.Context.StoryJournalist.Where(sj => sj.JournalistId == request.JournalistId && sj.StoryId == request.StoryId).FirstOrDefault();

            if (storyJournalist == null)
            {
                throw new EntityNotFoundException();
            }

            this.Context.StoryJournalist.Remove(storyJournalist);
            this.Context.SaveChanges();
        }
Ejemplo n.º 2
0
        public void Execute(StoryJournalistDto request)
        {
            var storyJournalist = this.Context.StoryJournalist.Where(sj => sj.JournalistId == request.JournalistId && sj.StoryId == request.StoryId).FirstOrDefault();

            if (storyJournalist != null)
            {
                throw new EntityAlreadyExistsException();
            }

            this.Context.StoryJournalist.Add(new StoryJournalist {
                JournalistId = request.JournalistId,
                StoryId      = request.StoryId
            });

            this.Context.SaveChanges();
        }