示例#1
0
        public EditOrderDetailCommandValidator(INorthwindContext context)
        {
            _context = context;

            RuleFor(x => x.OrderId).NotEmpty().WithMessage(ValidationErrorMessages.RequiredMessage);
            RuleFor(x => x.ProductId).NotEmpty().WithMessage(ValidationErrorMessages.RequiredMessage);
            RuleFor(x => x.EmployeeId).NotEmpty().WithMessage(ValidationErrorMessages.RequiredMessage);
            RuleFor(x => x.OrderDate).NotEmpty().WithMessage(ValidationErrorMessages.RequiredMessage);

            RuleFor(x => x.CustomerId).Cascade(CascadeMode.StopOnFirstFailure)
            .NotEmpty().WithMessage(ValidationErrorMessages.RequiredMessage)
            .Length(3, 100).WithMessage(ValidationErrorMessages.LengthError);

            RuleFor(x => x.ShipAddress).Cascade(CascadeMode.StopOnFirstFailure)
            .NotEmpty().WithMessage(ValidationErrorMessages.RequiredMessage)
            .Length(10, 300).WithMessage(ValidationErrorMessages.LengthError);

            RuleFor(x => x.ShipPostalCode).Cascade(CascadeMode.StopOnFirstFailure)
            .NotEmpty().WithMessage(ValidationErrorMessages.RequiredMessage)
            .Matches("[0-9]{5}-[0-9]{4}").WithMessage(ValidationErrorMessages.WrongFormat);

            RuleFor(x => x.RequiredDate).Cascade(CascadeMode.StopOnFirstFailure)
            .NotEmpty().WithMessage(ValidationErrorMessages.RequiredMessage)
            .GreaterThan(x => x.OrderDate).When(x => x.OrderDate.HasValue).WithMessage(ValidationErrorMessages.LesserThan)
            .LessThan(x => x.ShippedDate).When(x => x.ShippedDate.HasValue).WithMessage(ValidationErrorMessages.LesserThan);

            RuleFor(x => x.Quantity).Cascade(CascadeMode.StopOnFirstFailure)
            .NotEmpty().WithMessage(ValidationErrorMessages.RequiredMessage)
            .MustAsync((q, v, ct) => isQuantityValid(q.OrderId, q.ProductId, v)).WithMessage(ValidationErrorMessages.QuantityNotSufficient);
        }
示例#2
0
 public RepositoryBase(INorthwindContext northwindContext)
 {
     this.northwindContext = northwindContext;
 }
示例#3
0
 protected ReportBase(INorthwindContext dbContext)
 {
     NorthwindContext = dbContext;
 }
 public IsQuantityValidQueryHandler(INorthwindContext context)
 {
     _context = context;
 }
 public ProductRepository()
 {
     _context = new NorthwindContext();
 }
示例#6
0
 public UnitOfWork(NorthwindContext context)
 {
     _context = context;
 }
示例#7
0
 public GetDropDownListDataQueryhandler(INorthwindContext context)
 {
     _context = context;
 }
示例#8
0
 public GenericRepository(/*ILogger<GenericRepository<T>> logger, */ INorthwindContext dbContext)
 {
     //this.logger = logger;
     this.dbContext = dbContext;
     dbSet          = dbContext.Set <T>();
 }
示例#9
0
 public void NorthwindTestInitialize()
 {
     _context    = new NorthwindContext("Northwind");
     _repository = new Repository(_context);
 }
 public DeleteProductCommandHandler(INorthwindContext context)
 {
     _context = context;
 }
示例#11
0
 public NorthwindRepository(INorthwindContext northwindDb)
 {
     _northwindDb = northwindDb;
 }
示例#12
0
 public UnitOfWork(/*ILoggerFactory loggerFactory, */ INorthwindContext dbContext)
 {
     //this.loggerFactory = loggerFactory;
     //logger = loggerFactory.CreateLogger<UnitOfWork>();
     this.dbContext = dbContext;
 }
示例#13
0
 public CategoryController(INorthwindContext context)
 {
     //Utilizar el contexto doble de prueba
     this.Context = context;
 }
示例#14
0
 public CategoryController()
 {
     //Instanciar contexto entoty framwork (Produccion)
     Context = new NorthWindContext();
 }
示例#15
0
 public SearchOrderDetailsQueryHandler(INorthwindContext context)
 {
     _context = context;
 }
示例#16
0
 public HomeController(INorthwindContext dbContext, IMailSender mailSender)
 {
     _northwindDbContext = dbContext;
     _mailSender         = mailSender;
 }
示例#17
0
 public SupplierRepository(INorthwindContext northwindDb)
     : base(northwindDb)
 {
     _northwindDb = northwindDb;
 }
示例#18
0
 public GetProductDetailsQueryHandler(INorthwindContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
示例#19
0
 private static Dictionary <DropDownListIdentifier, IQueryable <KeyValue> > _configData(INorthwindContext context)
 {
     return(new Dictionary <DropDownListIdentifier, IQueryable <KeyValue> >()
     {
         { DropDownListIdentifier.Categories, context.Categories.Select(x => new KeyValue(x.CategoryId, x.CategoryName)) },
         { DropDownListIdentifier.Suppliers, context.Suppliers.Select(x => new KeyValue(x.SupplierId, x.CompanyName)) },
         { DropDownListIdentifier.Employees, context.Employees.Select(x => new KeyValue(x.EmployeeId, $"{x.FirstName} {x.LastName}")) },
         { DropDownListIdentifier.Customers, context.Customers.Select(x => new KeyValue(x.CustomerId, x.CompanyName)) },
         { DropDownListIdentifier.Countries, context.Customers.Select(x => new KeyValue(x.Country, x.Country)) },
     });
 }
示例#20
0
 public CategoryController()
 {
     Context = new NorthwindContext();
 }
示例#21
0
 public UnitOfWork()
 {
     _context = new NorthwindContext();
 }
示例#22
0
 public CategoryController(INorthwindContext context)
 {
     this.Context = context;
 }
 public ProductRepository(INorthwindContext context)
 {
     _context = context;
 }
示例#24
0
 public CategoryRepository(INorthwindContext northwindDb)
     : base(northwindDb)
 {
     _northwindDb = northwindDb;
 }
示例#25
0
 public SalesReport(INorthwindContext dbContext) : base(dbContext)
 {
 }
示例#26
0
 public EditProductCommandHandler(INorthwindContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
示例#27
0
 public UnitOfWork(IGameStoreContext gameStoreDb, INorthwindContext northwindDb)
 {
     _gameStoreDb = gameStoreDb;
     _northwindDb = northwindDb;
 }
示例#28
0
 public GetOrderDetailQueryHandler(INorthwindContext context)
 {
     _context = context;
 }
 public IsProductNameUniqueQueryHandler(INorthwindContext context)
 {
     _context = context;
 }
示例#30
0
 public ProductRepository(INorthwindContext northwindContext) : base(northwindContext)
 {
 }
示例#31
0
 public SearchProductQueryHandler(INorthwindContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
示例#32
0
 public EditOrderDetailCommandHandler(INorthwindContext context)
 {
     _context = context;
 }
示例#33
0
 public ProductRepository(INorthwindContext northwindDb)
     : base(northwindDb)
 {
     _northwindDb = northwindDb;
 }
示例#34
0
 public Repository(INorthwindContext context)
 {
     _context = context;
 }