예제 #1
0
        public async Task AddDrinkAsyncTestAsync()
        {
            var options = new DbContextOptionsBuilder <CoffeeDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            using (var context = new CoffeeDbContext(options))
            {
                var newDrink = new Drink {
                    DrinkName = "test", Description = "test", Price = 100, CategoryId = 1
                };
                var service = new DrinkRepository(context);
                await service.AddDrinkAsync(newDrink);
            }

            using (var context = new CoffeeDbContext(options))
            {
                var newDrink = new Drink {
                    DrinkName = "test", Description = "test", Price = 100, CategoryId = 1
                };
                var result = context.Drinks.Single();
                //Assert.IsNull(result);
                Assert.AreEqual(1, context.Drinks.Count());
                Assert.AreEqual(newDrink.DrinkName, result.DrinkName);
            }
        }
예제 #2
0
 public OrderRepository(
     CoffeeDbContext context,
     IShoppingCartService shoppingCartService)
 {
     _context             = context;
     _shoppingCartService = shoppingCartService;
 }
예제 #3
0
        public async System.Threading.Tasks.Task CheckRequestTestAsync()
        {
            var options = new DbContextOptionsBuilder <CoffeeDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            using (var context = new CoffeeDbContext(options))
            {
                var service = new TableRepository(context);

                TableRequest table = new TableRequest
                {
                    Id          = 1,
                    FirstName   = "FirstName",
                    LastName    = "LastName",
                    Date        = DateTime.Now.ToString(),
                    Status      = "Waiting",
                    Note        = "Test",
                    PhoneNumber = "123456",
                    Time        = DateTime.Now.AddDays(2).ToString()
                };

                await service.AddRequestAsync(table);
            }

            using (var context = new CoffeeDbContext(options))
            {
                Assert.AreEqual(1, context.TableRequests.Count());

                var service = new TableRepository(context);
                await service.CheckRequest(1, "Done");

                Assert.AreEqual("Done", context.TableRequests.Single().Status);
            }
        }
예제 #4
0
        public async Task GetDrinksTestAsync()
        {
            var options = new DbContextOptionsBuilder <CoffeeDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            using (var context = new CoffeeDbContext(options))
            {
                var newDrink1 = new Drink {
                    DrinkName = "test", Description = "test", Price = 100, CategoryId = 1, Category = new Category()
                };
                var newDrink2 = new Drink {
                    DrinkName = "test2", Description = "test2", Price = 200, CategoryId = 2, Category = new Category()
                };
                var service = new DrinkRepository(context);
                await service.AddDrinkAsync(newDrink1);

                await service.AddDrinkAsync(newDrink2);
            }

            using (var context = new CoffeeDbContext(options))
            {
                var service = new DrinkRepository(context);
                var result  = service.GetDrinks();
                Assert.AreEqual(2, result.Count());
            }
        }
예제 #5
0
        public AddProduct()
        {
            InitializeComponent();
            _db = new CoffeeDbContext();

            cboCategory.DataSource    = _db.ProductsTypes.ToList();
            cboCategory.DisplayMember = "Description";
            cboCategory.ValueMember   = "Id";
        }
        public async Task GetCategoryByIdAsyncTestAsync()
        {
            var options = new DbContextOptionsBuilder <CoffeeDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            using (var context = new CoffeeDbContext(options))
            {
                var doanCategory = new Category
                {
                    Id           = 1,
                    CategoryName = "Đồ ăn",
                    Drinks       = new List <Drink>()
                };

                var thucuongCategory = new Category
                {
                    Id           = 2,
                    CategoryName = "Thức uống",
                    Drinks       = new List <Drink>()
                };

                var coffeeCategory = new Category
                {
                    Id           = 3,
                    CategoryName = "Coffee",
                    Drinks       = new List <Drink>()
                };

                var trangmiengCategory = new Category
                {
                    Id           = 4,
                    CategoryName = "Tráng miệng",
                    Drinks       = new List <Drink>()
                };

                context.Categories.Add(doanCategory);
                context.Categories.Add(thucuongCategory);
                context.Categories.Add(coffeeCategory);
                context.Categories.Add(trangmiengCategory);
                context.SaveChanges();
            }

            using (var context = new CoffeeDbContext(options))
            {
                var service = new CategoryRepository(context);

                var result = await service.GetCategoryByIdAsync(4);

                //Assert.AreEqual(4, context.Categories.Count());
                Assert.AreEqual(4, result.Id);
            }
        }
예제 #7
0
        public async System.Threading.Tasks.Task GetRequestsTestAsync()
        {
            var options = new DbContextOptionsBuilder <CoffeeDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            using (var context = new CoffeeDbContext(options))
            {
                var service = new TableRepository(context);

                TableRequest table1 = new TableRequest
                {
                    Id          = 1,
                    FirstName   = "FirstName",
                    LastName    = "LastName",
                    Date        = DateTime.Now.ToString(),
                    Status      = "Waiting",
                    Note        = "Test",
                    PhoneNumber = "123456",
                    Time        = DateTime.Now.AddDays(2).ToString()
                };

                TableRequest table2 = new TableRequest
                {
                    Id          = 2,
                    FirstName   = "FirstName1",
                    LastName    = "LastName1",
                    Date        = DateTime.Now.ToString(),
                    Status      = "Waiting1",
                    Note        = "Test1",
                    PhoneNumber = "123456",
                    Time        = DateTime.Now.AddDays(2).ToString()
                };

                await service.AddRequestAsync(table1);

                await service.AddRequestAsync(table2);
            }

            using (var context = new CoffeeDbContext(options))
            {
                Assert.AreEqual(2, context.TableRequests.Count());

                var service = new TableRepository(context);
                var result  = service.GetRequests();

                Assert.AreEqual(2, result.Count());
            }
        }
예제 #8
0
        public ViewProducts()
        {
            InitializeComponent();

            _db = new CoffeeDbContext();

            dataGridView1.DataSource = _db.Products.ToList();

            dataGridView1.Columns["ProductType"].Visible   = false;
            dataGridView1.Columns["ProductTypeId"].Visible = false;

            cboFilter.DataSource    = _db.ProductsTypes.ToList();
            cboFilter.DisplayMember = "Description";
            cboFilter.ValueMember   = "Id";
        }
        public DictionaryRepository(CoffeeDbContext dbContext, IAppLogger <DictionaryRepository <T> > appLogger)
        {
            this._dbContext = dbContext;
            this._appLogger = appLogger;

            //GetRoles().Wait();
            //GetAreas().Wait();

            IEnumerable <Role> roles = _dbContext.Roles.ToList();
            IEnumerable <Area> areas = _dbContext.Areas.ToList();

            var tasks = new List <Task>()
            {
                GetRoles(roles), GetAreas(areas)
            };

            WhenAllTasks(tasks);
        }
예제 #10
0
        private void GenerateGraph()
        {
            using (var _db = new CoffeeDbContext())
            {
                var query = from product in _db.TransactionItems
                            group product by product.Product.Description
                            into g
                            select new { ProductId = g.Key, TotalUnitsSold = g.Count() };

                chart1.DataSource = query;
                chart1.Series["Series1"].XValueMember  = "ProductId";
                chart1.Series["Series1"].YValueMembers = "TotalUnitsSold";

                chart1.Series["Series1"].Name = "Products";

                chart1.DataBind();
                chart1.Show();
            }
        }
 public OwnerConfirmationRepository(CoffeeDbContext context) : base(context)
 {
 }
예제 #12
0
 public HomeController(CoffeeDbContext coffeeDbContext, IUnitOfWork unitOfWork)
 {
     _unitOfWork = unitOfWork;
 }
예제 #13
0
 public AreaRepository(CoffeeDbContext context) : base(context)
 {
 }
예제 #14
0
 public TableRepository(CoffeeDbContext coffeeDbContext)
 {
     _coffeeDbContext = coffeeDbContext;
 }
예제 #15
0
 public UnitOfWork(CoffeeDbContext coffeeDbContext)
 {
     _coffeeDbContext = coffeeDbContext;
     InitRepository();
 }
예제 #16
0
 public CategoryRepository(CoffeeDbContext coffeeDbContext)
 {
     _coffeeDbContext = coffeeDbContext;
 }
예제 #17
0
        public Form1()
        {
            InitializeComponent();

            _db = new CoffeeDbContext();
        }
예제 #18
0
 private ShoppingCartService(CoffeeDbContext context)
 {
     _context = context;
 }
예제 #19
0
 public EfRepository(CoffeeDbContext dbContext)
 {
     _dbContext = dbContext;
 }
예제 #20
0
 public RoasterTagRepository(CoffeeDbContext dbContext)
 => Context = dbContext ?? throw new ArgumentNullException(nameof(CoffeeDbContext));
예제 #21
0
 public UserDao()
 {
     db = new CoffeeDbContext();//Khởi tạo db
 }
예제 #22
0
 public StatisticController(CoffeeDbContext context)
 {
     _context = context;
 }
예제 #23
0
 public PictureRequestRepository(CoffeeDbContext coffeeDbContext)
 => _coffeeDbContext = coffeeDbContext;
예제 #24
0
 public HomeController(CoffeeDbContext db)
 {
     _db = db;
 }
예제 #25
0
 public DrinkRepository(CoffeeDbContext coffeeDbContext)
 {
     _coffeeDbContext = coffeeDbContext;
 }
예제 #26
0
 public TagRepository(CoffeeDbContext context)
 => Context = context ?? throw new ArgumentNullException(nameof(CoffeeDbContext));
예제 #27
0
 public OwnerRepository(CoffeeDbContext context) : base(context)
 {
 }
예제 #28
0
 public CoffeeService(CoffeeDbContext context)
 {
     this._context = context;
 }
예제 #29
0
 private void DoLoading(object sender, DoWorkEventArgs e)
 {
     CoffeeDbContext dbContext = new CoffeeDbContext();
 }
예제 #30
0
 public RoasterRequestRepository(CoffeeDbContext context,
                                 ILogger logger)
 => _context = context ?? throw new ArgumentNullException(nameof(CoffeeDbContext));