public GetValuesListQueryHandler(ITemplateDbContext context,
                                  IMapper mapper,
                                  IUriService uriService)
 {
     _context    = context;
     _mapper     = mapper;
     _uriService = uriService;
 }
Example #2
0
        public CreateValueCommandValidator(ITemplateDbContext context)
        {
            _context = context;

            RuleFor(v => v.ValueNumber)
            .NotNull().WithMessage("Value can't be empty!")
            .GreaterThanOrEqualTo(0).WithMessage("Value can't be negative!")
            .MustAsync(BeUniqueValueAsync).WithMessage("The specified value already exists.");
        }
        private static async Task SeedValuesAsync(ITemplateDbContext context)
        {
            var values = new List <Value>
            {
                new Value(1),
                new Value(2),
                new Value(3),
            };

            await context.Values.AddRangeAsync(values);
        }
        public static async Task SeedDataAsync(ITemplateDbContext context)
        {
            if (context.Customers.Any())
            {
                return;
            }
            await SeedValuesAsync(context);
            await SeedOrdersAsync(context);
            await SeedCustomersAsync(context);

            await context.SaveChangesAsync(CancellationToken.None);
        }
        private static async Task SeedCustomersAsync(ITemplateDbContext context)
        {
            _customers.Add(1, new Customer
            {
                Address     = "Avda. de la Constitución 2222",
                CompanyName = "Ana Trujillo Emparedados y helados",
                ContactName = "Ana Trujillo",
                Country     = "Mexico",
                PostalCode  = "05021",
                //IsActive = true,
                //Created = DateTime.Now,
                //CreatedBy = "*****@*****.**",
                //LastModified = null,
                //LastModifiedBy = "*****@*****.**"
            }.AddOrders(_orders[1])
                           );

            _customers.Add(2, new Customer
            {
                Address     = "Obere Str. 57",
                CompanyName = "Alfreds Futterkiste",
                ContactName = "Maria Anders",
                Country     = "Germany",
                PostalCode  = "12209",
                //IsActive = true,
                //Created = DateTime.Now,
                //CreatedBy = "*****@*****.**",
                //LastModified = null,
                //LastModifiedBy = "*****@*****.**"
            }.AddOrders(_orders[2], _orders[3])
                           );
            _customers.Add(3, new Customer
            {
                Address     = "Mataderos  2312",
                CompanyName = "Antonio Moreno Taquería",
                ContactName = "Antonio Moreno",
                Country     = "Mexico",
                PostalCode  = "05023",
                //IsActive = true,
                //Created = DateTime.Now,
                //CreatedBy = "*****@*****.**",
                //LastModified = null,
                //LastModifiedBy = "*****@*****.**"
            }
                           );


            await context.Customers.AddRangeAsync(_customers.Values.AsEnumerable());
        }
        private static async Task SeedOrdersAsync(ITemplateDbContext context)
        {
            _orders.Add(1, new Order
            {
                OrderName = "Order1",
                Priority  = PriorityLevel.Low,
                //IsActive = true,
                //Created = DateTime.Now,
                //CreatedBy = "*****@*****.**",
                //LastModified = null,
                //LastModifiedBy = "*****@*****.**"
            }
                        );
            _orders.Add(2, new Order
            {
                OrderName = "Order2",
                Priority  = PriorityLevel.Medium,
                //IsActive = true,
                //context.Entry(Order).Property("IsActive").CurrentValue = true,
                //context.Entry(Order).Property("Created").CurrentValue = DateTime.Now,
                //CreatedBy = "*****@*****.**",
                //LastModified = null,
                //LastModifiedBy = "*****@*****.**"
            }
                        );
            _orders.Add(3, new Order
            {
                OrderName = "Order3",
                Priority  = PriorityLevel.High,
                //IsActive = true,
                //Created = DateTime.Now,
                //CreatedBy = "*****@*****.**",
                //LastModified = null,
                //LastModifiedBy = "*****@*****.**"
            }
                        );

            await context.Orders.AddRangeAsync(_orders.Values.AsEnumerable());
        }
Example #7
0
 public GetTemplateAllQueryHandler(ITemplateDbContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
 public CreateManagerCommandHandler(ITemplateDbContext context)
 {
     this.context = context;
 }
 public CreateValueCommandHandler(ITemplateDbContext context, IMediator mediator)
 {
     _context  = context;
     _mediator = mediator;
 }
 public SampleDataSeeder(ITemplateDbContext context)
 {
     _context = context;
 }
Example #11
0
 public TemplateData(ITemplateDbContext context)
 {
     this.context      = context;
     this.repositories = new Dictionary <Type, object>();
 }
Example #12
0
 public SeedSampleDataCommandHandler(ITemplateDbContext context)
 {
     _context = context;
 }
Example #13
0
 public GetAllManagersListQueryHandler(ITemplateDbContext context, IMapper mapper)
 {
     this.context = context;
     this.mapper  = mapper;
 }
 public CreateManagerCommandHandler(ITemplateDbContext context, IMediator mediator)
 {
     this.context  = context;
     this.mediator = mediator;
 }
 public CreateTemplateEntityCommandHandler(ITemplateDbContext context)
 {
     _context = context;
 }
 public GetManagerByIdQueryHandler(ITemplateDbContext context)
 {
     this.context = context;
 }