Example #1
0
        public OrderWithProductsQueryValidator(IShopContext context)
        {
            _context = context;

            RuleFor(x => x.Id)
            .NotEmpty()
            .WithMessage(CommonErrors.ShouldNotBeEmpty)
            .MustAsync(OrderExists)
            .WithMessage((query, id) => ValidatorMessageExtensions.FormatMessage(OrderWithProductsQueryErrors.OrderDoesNotExist, id));
        }
Example #2
0
        public ProductLineItemModelValidator(IShopContext context)
        {
            _context = context;

            RuleFor(x => x.Id)
            .MustAsync(ProductExists)
            .WithFormattedMessage(CommonCustomFormatterErrors.EntityShouldExist, nameof(Product));

            RuleFor(x => x.Quantity)
            .GreaterThan(0)
            .WithMessage(CommonErrors.ShouldBeGreaterThan0);
        }
        public CreateOrderCommandValidator(IShopContext context)
        {
            _context = context;

            RuleFor(x => x.Products)
            .NotEmpty()
            .WithMessage(CreateOrderCommandErrors.OrderShouldContainAtLeastOneProduct);

            RuleForEach(x => x.Products)
            .SetValidator(new ProductLineItemModelValidator(context))
            .When(x => x.Products != null && x.Products.Any());
        }
Example #4
0
        public CreateProductCommandValidator(IShopContext context)
        {
            _context = context;

            RuleFor(x => x.Name)
            .NotEmpty()
            .WithMessage(CommonErrors.ShouldNotBeEmpty)
            .MustAsync(ShouldBeUniqueName)
            .WithMessage(CommonErrors.ShouldBeUnique);

            RuleFor(x => x.Price)
            .GreaterThan(0)
            .WithMessage(CommonErrors.ShouldBeGreaterThan0);

            RuleFor(x => x.ProductCategoryId)
            .MustAsync(ProductCategoryExists)
            .WithFormattedMessage(CommonCustomFormatterErrors.EntityShouldExist, nameof(ProductCategory));
        }
Example #5
0
 private Shop()
 {
     context = ShopContextFactory.CreateShopContext();
     //memoryItems.AddRange(context.GetAllItems());
     maxId = Items.Max(item => item.ArticleNumber);
 }
 public OrderingsController()
 {
     db = new ShopContext();
 }
Example #7
0
 public ProductCategoriesQueryHandler(IShopContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
Example #8
0
        //public ItemsRepository()
        //{
        //    _db = new ApplicationDbContext();
        //}

        public ItemsRepository(IShopContext db)
        {
            _db = db;
        }
Example #9
0
 public UsersController(IShopContext ShopContext)
 {
     this.db = ShopContext;
 }
Example #10
0
 public ProductManager(IShopContext shopContext, IMapper mapper)
 {
     _shopContext = shopContext;
     _mapper      = mapper;
 }
 public OrderWithProductsQueryHandler(IShopContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
Example #12
0
 public ProductService(IShopContext context)
 {
     _context = context;
 }
 public UserController_Old()
 {
     db = new ShopContext();
 }
Example #14
0
 public UserRepository(IShopContext context)
 {
     _context = context;
 }
Example #15
0
 public ProductRepository(IShopContext context)
 {
     _context = context;
 }
Example #16
0
 public UnitOfWork(IShopContext db)
 {
     _db = db;
 }
Example #17
0
 public CreateProductCommandHandler(IShopContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
 public UserController_Old(IShopContext context)
 {
     db = context;
 }
 public CreateOrderCommandHandler(IShopContext context)
 {
     _context = context;
 }
Example #20
0
 public ProductsController()
 {
     db = new ShopContext();
 }
Example #21
0
 public ShopTypeService(IShopContext context)
 {
     _context = context ?? throw new ArgumentNullException(nameof(context));
 }
Example #22
0
 public ShopRepository(IShopContext context)
 {
     this.context = context;
 }
Example #23
0
 public UsersController()
 {
     db = new ShopContext();
 }