public void Commit() { using (VendingMachineContext dbContext = VendingMachineContext.InstanceFactory()) { //dbContext.SaveChanges(); } }
public void InsertUser(UserRecord user) { using (VendingMachineContext dbContext = VendingMachineContext.InstanceFactory()) { dbContext.UserRecords.Add(user); dbContext.SaveChanges(); } }
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(); } }
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(); } }
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)); } }
public DbContextCreator(string connString) { if (string.IsNullOrEmpty(connString)) { _context = new VendingMachineContext(); } else { _context = new VendingMachineContext(connString); } }
public VendingMachineController( VendingMachineContext context, CoinChangerService coinChangerService, VendingMachineService vendingMachineService ) { _context = context; _coinChangerService = coinChangerService; _vendingMachineService = vendingMachineService; vendingMachineService.InitializeData(); }
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}"; }
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); }
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); }
public ProductRepository(VendingMachineContext context) { this._context = context; }
public GuestRepository(VendingMachineContext context) { this._context = context; }
public void TestSetup() { testContext = new VendingMachineContext(testDBName); testContext.Configuration.AutoDetectChangesEnabled = true; testContext.Database.CreateIfNotExists(); }
public AccountRepository(VendingMachineContext context) { this._context = context; }
public ClientController(VendingMachineContext context) { _context = context; }
public PurchaseRepository(VendingMachineContext context) { this._context = context; }
public AdminController(VendingMachineContext context, IHostEnvironment env) { _context = context; _hostingEnvironment = env; }