public DeleteSupplierCommandValidator(DoenerOrderContext dbContext) { RuleFor(x => x.Id) .NotEmpty() .Must(supplierId => dbContext.Suppliers.Any(s => s.Id == supplierId)) .WithMessage("Supplier does not exist"); }
public CreateProductForSupplierCommandValidator(DoenerOrderContext context) { RuleFor(x => x.SupplierId) .NotEmpty() .Must(supplierId => context.Suppliers.Any(s => s.Id == supplierId)) .WithMessage("Supplier does not exist"); RuleFor(x => x.Label) .NotEmpty(); RuleFor(x => x.Price) .NotNull(); }
public DeleteProductForSupplierCommandValidator(DoenerOrderContext dbContext) { RuleFor(x => x.SupplierId) .NotEmpty() .Must(supplierId => dbContext.Suppliers.Any(s => s.Id == supplierId)) .WithMessage("Supplier does not exist"); RuleFor(x => x.ProductId) .NotEmpty() .Must((command, productId) => dbContext.Products.Any(p => p.Id == productId && p.SupplierId == command.SupplierId)) .WithMessage("Product does not exist."); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, DoenerOrderContext dbContext, AppIdentityDbContext appIdentityDbContext) { dbContext.Database.Migrate(); appIdentityDbContext.Database.Migrate(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); SwaggerSetup.ConfigureApplication(app); } app.UseHttpsRedirection(); app.UseRouting(); JwtSetup.ConfigureApplication(app); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
public GetProductForSupplierByIdQueryHandler(DoenerOrderContext dbContext) { this.dbContext = dbContext; }
public CreateProductForSupplierCommandHandler(DoenerOrderContext dbContext) { this.dbContext = dbContext; }
public DeleteProductForSupplierCommandHandler(DoenerOrderContext context) { this.context = context; }
public GetAllProductsForSupplierQueryHandler(DoenerOrderContext dbContext) { this.dbContext = dbContext; }
public GetAllSuppliersQueryHandler(DoenerOrderContext dbContext) { this.dbContext = dbContext; }
public UpdateSupplierCommandHandler(DoenerOrderContext dbContext) { this.dbContext = dbContext; }