public CreateEpisodeCommandValidator(StarWarsSampleAppDbContext context)
        {
            _context = context;

            RuleFor(x => x.Name)
            .NotEmpty()
            .Must(BeUnique).WithMessage("The episode name has to be unique");
        }
        public EditEpisodeCommandValidator(StarWarsSampleAppDbContext context)
        {
            _context = context;

            RuleFor(x => x.Id)
            .NotEmpty()
            .Must(BeActive).WithMessage("This episode was deleted");

            RuleFor(x => x.Name)
            .NotEmpty()
            .Must(BeUnique).WithMessage("The episode name has to be unique");
        }
        public CreateCharacterCommandValidator(StarWarsSampleAppDbContext context)
        {
            _context = context;

            RuleFor(x => x.Name)
            .NotEmpty()
            .Must(BeUnique).WithMessage("The character name has to be unique");

            RuleFor(x => x.EpisodesIds)
            .NotEmpty()
            .Must(HaveAtLeastOneEpisode).WithMessage("Character has to star in at least one episode");
        }
        private StarWarsSampleAppDbContext GetDbContext()
        {
            var builder = new DbContextOptionsBuilder <StarWarsSampleAppDbContext>();

            builder.UseSqlServer(ConnectionString);

            var dbContext = new StarWarsSampleAppDbContext(builder.Options);

            dbContext.Database.EnsureCreated();

            return(dbContext);
        }
        public EditCharacterCommandValidator(StarWarsSampleAppDbContext context)
        {
            _context = context;

            RuleFor(x => x.Name)
            .NotEmpty()
            .Must(BeUnique).WithMessage("The character name has to be unique");

            RuleFor(x => x.EpisodesIds)
            .NotEmpty()
            .Must(HaveAtLeastOneEpisode).WithMessage("Character has to star in at least one episode");

            RuleFor(x => x.FriendsIds)
            .Must(DoNotHaveRelationWithItself).WithMessage("Character cannot be friend with itself");
        }
示例#6
0
 public DeleteCharacterCommandHandler(StarWarsSampleAppDbContext context)
 {
     _context = context;
 }
 public GetEpisodeQueryHandler(StarWarsSampleAppDbContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
示例#8
0
 public CreateCharacterCommandHandler(StarWarsSampleAppDbContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
示例#9
0
 public DeleteEpisodeCommandHandler(StarWarsSampleAppDbContext context)
 {
     _context = context;
 }
示例#10
0
 public GetCharacterQueryHandler(StarWarsSampleAppDbContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
 public EpisodeBuilder SaveChanges(StarWarsSampleAppDbContext context)
 {
     context.Episodes.AddRange(_episodes);
     context.SaveChanges();
     return(this);
 }
示例#12
0
 public EditEpisodeCommandHandler(StarWarsSampleAppDbContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
示例#13
0
 public CharacterBuilder SaveChanges(StarWarsSampleAppDbContext context)
 {
     context.Characters.AddRange(_characters);
     context.SaveChanges();
     return(this);
 }