コード例 #1
0
 public void Commit()
 {
     using (VendingMachineContext dbContext = VendingMachineContext.InstanceFactory())
     {
         //dbContext.SaveChanges();
     }
 }
コード例 #2
0
 public void InsertUser(UserRecord user)
 {
     using (VendingMachineContext dbContext = VendingMachineContext.InstanceFactory())
     {
         dbContext.UserRecords.Add(user);
         dbContext.SaveChanges();
     }
 }
コード例 #3
0
        public void DeleteUser(int id)
        {
            using (VendingMachineContext dbContext = VendingMachineContext.InstanceFactory())
            {
                UserRecord userRecord = dbContext.UserRecords.Select(x => x).Where(x => x.Id == id).First();

                dbContext.UserRecords.Remove(userRecord);
                dbContext.SaveChanges();
            }
        }
コード例 #4
0
        public void UpdateUser(UserRecord user)
        {
            using (VendingMachineContext dbContext = VendingMachineContext.InstanceFactory())
            {
                UserRecord userRecord = dbContext.UserRecords.Select(x => x).Where(x => x.Id == user.Id).First();

                user.CopyTo(ref userRecord);
                dbContext.SaveChanges();
            }
        }
コード例 #5
0
        public User FindById(int id)
        {
            UsersModelMapper map = new UsersModelMapper();

            using (VendingMachineContext dbContext = VendingMachineContext.InstanceFactory())
            {
                UserRecord userRecord = dbContext.UserRecords.Select(x => x).Where(x => x.Id == id).First();

                return(map.MapFromTable(userRecord));
            }
        }
コード例 #6
0
 public DbContextCreator(string connString)
 {
     if (string.IsNullOrEmpty(connString))
     {
         _context = new VendingMachineContext();
     }
     else
     {
         _context = new VendingMachineContext(connString);
     }
 }
コード例 #7
0
        public VendingMachineController(
            VendingMachineContext context,
            CoinChangerService coinChangerService,
            VendingMachineService vendingMachineService
            )
        {
            _context               = context;
            _coinChangerService    = coinChangerService;
            _vendingMachineService = vendingMachineService;

            vendingMachineService.InitializeData();
        }
コード例 #8
0
        public MainWindow()
        {
            InitializeComponent();
            db = new VendingMachineContext();



            Sum.Content = $"{sum}";

            // Загрузка из БД в форму.

            var           moneyMachine  = db.MachineWallets;
            MachineWallet walletMachine = moneyMachine.Find(1);

            Machine1.Content  = $"{walletMachine.Quantity}";
            walletMachine     = moneyMachine.Find(2);
            Machine2.Content  = $"{walletMachine.Quantity}";                                           // Кошелёк автомата
            walletMachine     = moneyMachine.Find(3);
            Machine5.Content  = $"{walletMachine.Quantity}";
            walletMachine     = moneyMachine.Find(4);
            Machine10.Content = $"{walletMachine.Quantity}";

            var         moneyBuyer  = db.BuyerWallets;
            BuyerWallet walletBuyer = moneyBuyer.Find(1);

            Buyer1.Content  = $"{walletBuyer.Quantity}";
            walletBuyer     = moneyBuyer.Find(2);
            Buyer2.Content  = $"{walletBuyer.Quantity}";                                                    // Кошелёк пользователя
            walletBuyer     = moneyBuyer.Find(3);
            Buyer5.Content  = $"{walletBuyer.Quantity}";
            walletBuyer     = moneyBuyer.Find(4);
            Buyer10.Content = $"{walletBuyer.Quantity}";

            var            products = db.VendingMachines;
            VendingMachine product  = products.Find(1);

            Label1.Content            = $"{product.Product}, {product.Price}руб.";
            TeaPortion.Content        = $"{product.Quantity}";
            product                   = products.Find(2);
            Label2.Content            = $"{product.Product}, {product.Price}руб.";
            CoffeePortion.Content     = $"{product.Quantity}";                                            // Количество продуктов
            product                   = products.Find(3);
            Label3.Content            = $"{product.Product}, {product.Price}руб.";
            CoffeeMilkPortion.Content = $"{product.Quantity}";
            product                   = products.Find(4);
            Label4.Content            = $"{product.Product}, {product.Price}руб.";
            JuicePortion.Content      = $"{product.Quantity}";
        }
コード例 #9
0
        public UserPrivilegeEnum GetUserPrivilege(string userName, string userPass)
        {
            UserPrivilegeEnum privilege;

            using (VendingMachineContext dbContext = VendingMachineContext.InstanceFactory())
            {
                string userPrivlege = dbContext.UserRecords.Where(x => string.Compare(x.UserName, userName, true) == 0 &&
                                                                  string.Compare(x.UserPassword, userPass, true) == 0)
                                      .Select(x => x.Privilege).First();
                //Enumumeration.Parse(userPrivlege, out privilege);

                privilege = Enumeration.FromDisplayName <UserPrivilegeEnum>(userPrivlege);
            }

            return(privilege);
        }
コード例 #10
0
        public List <User> GetAll()
        {
            List <User>      users = new List <User>();
            UsersModelMapper map   = new UsersModelMapper();

            using (VendingMachineContext dbContext = VendingMachineContext.InstanceFactory())
            {
                List <UserRecord> userRecords = dbContext.UserRecords.Select(x => x).ToList();

                foreach (UserRecord item in userRecords)
                {
                    users.Add(map.MapFromTable(item));
                }
            }

            return(users);
        }
コード例 #11
0
 public ProductRepository(VendingMachineContext context)
 {
     this._context = context;
 }
コード例 #12
0
 public GuestRepository(VendingMachineContext context)
 {
     this._context = context;
 }
コード例 #13
0
 public void TestSetup()
 {
     testContext = new VendingMachineContext(testDBName);
     testContext.Configuration.AutoDetectChangesEnabled = true;
     testContext.Database.CreateIfNotExists();
 }
コード例 #14
0
 public AccountRepository(VendingMachineContext context)
 {
     this._context = context;
 }
コード例 #15
0
 public ClientController(VendingMachineContext context)
 {
     _context = context;
 }
コード例 #16
0
 public PurchaseRepository(VendingMachineContext context)
 {
     this._context = context;
 }
コード例 #17
0
 public AdminController(VendingMachineContext context, IHostEnvironment env)
 {
     _context            = context;
     _hostingEnvironment = env;
 }