Exemplo n.º 1
0
        private void HandlePropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            switch (e.PropertyName)
            {
            case nameof(SelectedSupplier):
            {
                var suppliersId = _selectedSupplier?.TheEntity.SupplierID ?? -1;

                using (var db = new RetailDbContext())
                {
                    _selectableProducts = db
                                          .Products
                                          .Where(product => product.SupplierID == suppliersId)
                                          .OrderBy(n => n.Description)
                                          .Select(n => new ProductVM {
                            IsNew = false, TheEntity = n
                        })
                                          .ToList();
                }

                RaisePropertyChanged(nameof(SelectableProducts));
                PO.SetSupplier(SelectedSupplier);
                RaisePropertyChanged(nameof(PO));
                break;
            }

            case nameof(SelectedStore):
            {
                PO.SetStore(SelectedStore);
                RaisePropertyChanged(nameof(PO));
                break;
            }
            }
        }
Exemplo n.º 2
0
        private void Approve_Click(object sender, RoutedEventArgs e)
        {
            using (var db = new RetailDbContext())
            {
                db.Pos.Add(ViewModel.PO.TheEntity);
                db.SaveChanges();
            }

            DataContext = new POEntryViewModel();
        }
Exemplo n.º 3
0
        public static void SeedHostDb(RetailDbContext context)
        {
            context.SuppressAutoSetTenantId = true;

            //Host seed
            new InitialHostDbBuilder(context).Create();

            //Default tenant seed (in host database).
            new DefaultTenantBuilder(context).Create();
            new TenantRoleAndUserBuilder(context, 1).Create();
        }
        public static async Task SeedAsync(RetailDbContext dbContext)
        {
            dbContext.Database.EnsureCreated();

            if (!dbContext.Currencies.Any())
            {
                dbContext.Currencies.AddRange(GerPreconfiguredCurrency());

                await dbContext.SaveChangesAsync();
            }
        }
Exemplo n.º 5
0
        public static Product CreateProduct(this RetailDbContext db)
        {
            var id      = IdFactory.Next();
            var product = new Product
            {
                ProductName = $"Product {id}",
                Active      = true,
                Price       = id * 2 + 0.99m,
                SalesPrice  = id + 0.99m,
            };

            db.Add(product);

            return(product);
        }
 public void OnActionExecuted(ActionExecutedContext filterContext)
 {
     using (var context = new RetailDbContext()) {
         var productsSelectListItems = new List <SelectListItem>();
         var products = context.Products.AsEnumerable();
         foreach (Product product in products)
         {
             productsSelectListItems.Add(new SelectListItem()
             {
                 Text  = product.Name,
                 Value = product.Id.ToString()
             });
         }
         filterContext.Controller.ViewBag.ProductsSelectListItems = productsSelectListItems;
     }
 }
Exemplo n.º 7
0
 public void OnActionExecuted(ActionExecutedContext filterContext)
 {
     using (var context = new RetailDbContext()) {
         var categorySelectListItems = new List <SelectListItem>();
         var categories = context.Categories.AsEnumerable();
         foreach (Category category in categories)
         {
             categorySelectListItems.Add(new SelectListItem()
             {
                 Text  = category.Name,
                 Value = category.Id.ToString()
             });
         }
         filterContext.Controller.ViewBag.CategoriesSelectListItems = categorySelectListItems;
     }
 }
 public void OnActionExecuted(ActionExecutedContext filterContext)
 {
     using (var context = new RetailDbContext()) {
         var employeesSelectListItems = new List <SelectListItem>();
         var employees = context.Employees.AsEnumerable();
         foreach (Employee employee in employees)
         {
             employeesSelectListItems.Add(new SelectListItem()
             {
                 Text  = employee.LastName + ", " + employee.FirstName,
                 Value = employee.Id.ToString()
             });
         }
         filterContext.Controller.ViewBag.EmployeesSelectListItems = employeesSelectListItems;
     }
 }
 public void OnActionExecuted(ActionExecutedContext filterContext)
 {
     using (var context = new RetailDbContext()) {
         var vendorsSelectListItems = new List <SelectListItem>();
         var vendors = context.Vendors.AsEnumerable();
         foreach (Vendor vendor in vendors)
         {
             vendorsSelectListItems.Add(new SelectListItem()
             {
                 Text  = vendor.Name,
                 Value = vendor.Id.ToString()
             });
         }
         filterContext.Controller.ViewBag.VendorsSelectListItems = vendorsSelectListItems;
     }
 }
Exemplo n.º 10
0
 public void OnActionExecuted(ActionExecutedContext filterContext)
 {
     using (var context = new RetailDbContext()) {
         var customersSelectListItems = new List <SelectListItem>();
         var customers = context.Customers.AsEnumerable();
         foreach (Customer customer in customers)
         {
             customersSelectListItems.Add(new SelectListItem()
             {
                 Text  = customer.LastName + ", " + customer.FirstName,
                 Value = customer.Id.ToString()
             });
         }
         filterContext.Controller.ViewBag.CustomersSelectListItems = customersSelectListItems;
     }
 }
Exemplo n.º 11
0
        public static Store CreateStore(this RetailDbContext db)
        {
            var id    = IdFactory.Next();
            var store = new Store
            {
                Address     = $"{id} Main Street",
                City        = $"{id}ville",
                Province    = $"{id} District",
                Country     = $"{id}land",
                PostalCode  = $"{id}",
                PhoneNumber = $"({id}) {id}-{id}",
                StoreName   = $"Store {id}",
                Active      = true,
            };

            db.Add(store);

            return(store);
        }
Exemplo n.º 12
0
        public static Customer CreateCustomer(this RetailDbContext db)
        {
            var id       = IdFactory.Next();
            var customer = new Customer
            {
                FirstName   = $"Bob{id}",
                LastName    = $"Robertson{id}",
                Address     = $"{id} Main Street",
                City        = $"{id}ville",
                Province    = $"{id} District",
                Country     = $"{id}land",
                PostalCode  = $"{id}",
                PhoneNumber = $"({id}) {id}-{id}",
                Active      = true,
                Discount    = 0.0
            };

            db.Add(customer);

            return(customer);
        }
Exemplo n.º 13
0
 public InitialHostDbBuilder(RetailDbContext context)
 {
     _context = context;
 }
Exemplo n.º 14
0
 public ItemService(RetailDbContext dbContext)
 {
     _dbContext = dbContext;
 }
Exemplo n.º 15
0
 public LocationService(RetailDbContext dbContext)
 {
     _dbContext = dbContext;
 }
Exemplo n.º 16
0
 public TestSubscriptionPaymentBuilder(RetailDbContext context, int tenantId)
 {
     _context  = context;
     _tenantId = tenantId;
 }
Exemplo n.º 17
0
 public TestDataBuilder(RetailDbContext context, int tenantId)
 {
     _context  = context;
     _tenantId = tenantId;
 }
Exemplo n.º 18
0
 public DefaultLanguagesCreator(RetailDbContext context)
 {
     _context = context;
 }
Exemplo n.º 19
0
 public CurrencyRepository(RetailDbContext dbContext) : base(dbContext)
 {
 }
Exemplo n.º 20
0
 public TenantRoleAndUserBuilder(RetailDbContext context, int tenantId)
 {
     _context  = context;
     _tenantId = tenantId;
 }
Exemplo n.º 21
0
 public EfRepositoryBase(RetailDbContext dbContext)
 {
     _dbContext = dbContext ?? throw new ArgumentNullException(nameof(RetailDbContext));
 }
Exemplo n.º 22
0
 public RetailRepository(RetailDbContext dbContext)
 {
     _dbContext = dbContext;
 }
Exemplo n.º 23
0
 public DefaultSettingsCreator(RetailDbContext context)
 {
     _context = context;
 }
Exemplo n.º 24
0
 public DefaultEditionCreator(RetailDbContext context)
 {
     _context = context;
 }
Exemplo n.º 25
0
 public DefaultTenantBuilder(RetailDbContext context)
 {
     _context = context;
 }
 public TestOrganizationUnitsBuilder(RetailDbContext context, int tenantId)
 {
     _context  = context;
     _tenantId = tenantId;
 }
Exemplo n.º 27
0
 public HostRoleAndUserCreator(RetailDbContext context)
 {
     _context = context;
 }