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"); }
public DeleteCharacterCommandHandler(StarWarsSampleAppDbContext context) { _context = context; }
public GetEpisodeQueryHandler(StarWarsSampleAppDbContext context, IMapper mapper) { _context = context; _mapper = mapper; }
public CreateCharacterCommandHandler(StarWarsSampleAppDbContext context, IMapper mapper) { _context = context; _mapper = mapper; }
public DeleteEpisodeCommandHandler(StarWarsSampleAppDbContext context) { _context = context; }
public GetCharacterQueryHandler(StarWarsSampleAppDbContext context, IMapper mapper) { _context = context; _mapper = mapper; }
public EpisodeBuilder SaveChanges(StarWarsSampleAppDbContext context) { context.Episodes.AddRange(_episodes); context.SaveChanges(); return(this); }
public EditEpisodeCommandHandler(StarWarsSampleAppDbContext context, IMapper mapper) { _context = context; _mapper = mapper; }
public CharacterBuilder SaveChanges(StarWarsSampleAppDbContext context) { context.Characters.AddRange(_characters); context.SaveChanges(); return(this); }