Exemplo n.º 1
0
 public BalanceController(
     IAuthorizationService authorizationService,
     BalanceRepository balanceRepository
     ) : base(authorizationService)
 {
     this.balanceRepository = balanceRepository;
 }
Exemplo n.º 2
0
 public AccountInfo(APIKeyRepository keyRepo, BalanceRepository balanceRepo)
 {
     this.keyRepo     = keyRepo;
     this.balanceRepo = balanceRepo;
     logService       = new LogService();
     logService.CreateLogFile("AccountInfo");
 }
Exemplo n.º 3
0
        public async Task GetUpdateRemove()
        {
            var balanceRepository = new BalanceRepository();
            var notSoldRepository = new NotSoldRepository();
            var platform          = "testPlatform";
            var pair = "testPair";
            await balanceRepository.Add(platform, pair, 0.25m, 222.56m, false);

            var get = await balanceRepository.Get(platform, pair);

            Assert.That(get.Count, Is.EqualTo(1));

            await notSoldRepository.SetNotSold(platform, pair, false);

            var one = (await balanceRepository.Get(platform, pair)).First();

            Assert.That(one.NotSoldtDate, Is.Not.Null);
            Assert.That(one.NotSold, Is.EqualTo(1));

            Assert.That(one.Volume, Is.EqualTo(0.25m).Within(0.01));

            await notSoldRepository.SetNotSold(platform, pair, false);

            one = (await balanceRepository.Get(platform, pair)).First();
            Assert.That(one.NotSold, Is.EqualTo(2));

            await balanceRepository.Remove(platform, pair, false);

            get = await balanceRepository.Get(platform, pair);

            Assert.That(get.Count, Is.EqualTo(0));
        }
Exemplo n.º 4
0
        public ActionResult Update(string id)
        {
            var br    = new BalanceRepository();
            var found = br.Find(id);

            br.Update(found);

            return(RedirectToAction("RouteBalances"));
        }
Exemplo n.º 5
0
        public BalanceRepositoryTests()
        {
            context = FakeContextFactory.GetContext();
            context.ChangeTracker.LazyLoadingEnabled = false;
            var factory = new Mock <IContextFactory>(MockBehavior.Strict);

            factory.Setup(f => f.GetContext()).Returns(context);
            _repository = new BalanceRepository(factory.Object);
        }
Exemplo n.º 6
0
        public void Test_BalanceRepository_InitBalanceStored()
        {
            var repo = new BalanceRepository();

            Assert.AreEqual(0, repo.GetBalance());

            repo.InitBalance(100);

            Assert.AreEqual(100, repo.GetBalance());
        }
Exemplo n.º 7
0
        public KeyPanelScrin1(APIKeyRepository apiKeyRepository, BalanceRepository balanceRepository)
        {
            this.apiKeyRepository  = apiKeyRepository;
            this.balanceRepository = balanceRepository;

            ParametrBuy        = new ParametrBuySellView();
            ParametrSell       = new ParametrBuySellView();
            ParametrBuy.Coins  = SetPairs();
            ParametrSell.Coins = SetPairs();
        }
        public void GetBalanceTest()
        {
            IBalanceRepository repo = new BalanceRepository(_options);

            var symbol   = "btc";
            var response = repo.GetBalance(symbol);

            response.Wait();

            var balance = response.Result;

            Assert.NotNull(balance);
            Assert.True(balance.Count() > 0);
        }
Exemplo n.º 9
0
        public ActionResult HeadMenu()
        {
            BalanceRepository bl = new BalanceRepository();

            ViewBag.cust = Cust.SmalName;

            ViewBag.sm = bl.GetBalance(CustID, (int)abzHash.ContractID);
            contract   = db.Contracts.Find((int)abzHash.ContractID);
            if (contract != null)
            {
                ViewBag.Contract = "Договор № " + contract.Num;
            }

            return(PartialView());
        }
Exemplo n.º 10
0
        public ActionResult Privat(string id)
        {
            var user = UserManager.FindById(id);
            //MyMenu menu = (MyMenu)Session["Menu"];
            Cust cust            = db.Custs.Find(user.CustID);
            BalanceRepository bl = new BalanceRepository();

            //menu.Cust = cust.SmalName;
            //menu.sm = bl.GetBalance(cust.CustId,Menu.ContractId);
            //menu.CustId = cust.CustId;
            //menu.UserId = id;
            //menu.ChangeSelected(1, 1);
            //Session["Menu"] = menu;
            return(RedirectToAction("Index", "Custs", new { SelectedId = cust.CustId }));
        }
Exemplo n.º 11
0
 //constructor to assign the context and pass this context to all the repositories
 public UnitOfWork(SMC_DBEntities context)
 {
     _context    = context;
     User        = new UserRepository(_context);
     Role        = new RoleRepository(_context);
     Store       = new StoreRepository(_context);
     Group       = new GroupRepository(_context);
     Subgroup    = new SubgroupRepository(_context);
     Item        = new ItemRepository(_context);
     OrderType   = new OrderTypeRepository(_context);
     Order       = new OrderRepository(_context);
     OrderDetail = new OrderDetailRepository(_context);
     Balance     = new BalanceRepository(_context);
     Supplier    = new SupplierRepository(_context);
     Customer    = new CustomerRepository(_context);
     Employee    = new EmployeeRepository(_context);
 }
Exemplo n.º 12
0
        // [Authorize]
        public ActionResult Balance()
        {
            BalanceRepository repo = new BalanceRepository();

            ViewBag.MenuItem = "balance";
            int    ContractID;
            string dog = GetCookie("Dog");

            if (!String.IsNullOrWhiteSpace(dog))
            {
                ContractID = Convert.ToInt32(dog);
            }
            else
            {
                ContractID = 0;
            }

            return(View(repo.GetListBalance(Cust.CustId, ContractID)));
        }
Exemplo n.º 13
0
        public ActionResult Balance()
        {
            BalanceRepository repo = new BalanceRepository();
            //Menu.ChangeSelected(3, 1);
            //Session["Menu"] = Menu;
            int    ContractID;
            string dog = GetCookie("Dog");

            if (!String.IsNullOrWhiteSpace(dog))
            {
                ContractID = Convert.ToInt32(dog);
            }
            else
            {
                ContractID = 0;
            }

            return(View(repo.GetListBalance(Cust.CustId, ContractID)));
        }
Exemplo n.º 14
0
        public ActionResult Index(int SelectedCustId = 0, int SelectedContractId = -1)
        {
            //Определить контрагента и договор
            string qq  = User.Identity.Name;
            string cst = GetCookie("Cust");
            string dog = GetCookie("Dog");

            if (!String.IsNullOrWhiteSpace(cst) && !String.IsNullOrWhiteSpace(dog))
            {
                //Назначаем и быбираем контрагента и договор
                CustID     = Convert.ToInt32(cst);
                ContractID = Convert.ToInt32(dog);
            }
            else
            {
                //Получить данные по юзеру
                string usr = GetCookie("MyAuth");

                //cust = await db.Custs.FindAsync(user.CustID);
            }


            MyMenu menu = (MyMenu)Session["Menu"];

            if (SelectedContractId > 0 && menu.ContractId != SelectedContractId)
            {
                menu = ChangeControl(menu, SelectedCustId, SelectedContractId);
                ViewData["Contract"] = new SelectList(contracts, "ContractID", "Num", ContractID);
            }
            else
            {
                if (SelectedCustId > 0 && SelectedCustId != menu.CustId)
                {
                    menu = ChangeControl(menu, SelectedCustId, 0);
                }
                else
                {
                    menu = ChangeControl(menu, menu.CustId, 0);
                }

                if (ContractID > 0)
                {
                    ViewData["Contract"] = new SelectList(contracts, "ContractID", "Num", ContractID);
                }
                else
                {
                    ViewData["Contract"] = null;
                }
            }
            BalanceRepository bl = new BalanceRepository();

            menu.sm = bl.GetBalance(CustID, ContractID);

            menu.ChangeSelected(1, 1);
            Session["Menu"] = menu;

            //не верно для админа, однако работает?
            IEnumerable <OrgView> orgView = repo.GetCust(menu.UserId);

            ViewData["Cust"] = new SelectList(orgView, "ID", "Txt", CustID);

            return(View("Index", cust));
        }
Exemplo n.º 15
0
        public ActionResult Index(int SelectedCustId = -1, int SelectedContractId = -1)
        {
            string  auth    = GetCookie("Auth");
            AbzHash abzHash = hashRepo.GetHash(auth);
            string  usr     = abzHash.Email;

            if ((SelectedCustId > 0) && ((int)abzHash.CustID != SelectedCustId))
            {
                abzHash.CustID = SelectedCustId;
                contract       = repo.GetContract((int)abzHash.CustID);
                if (contract == null)
                {
                    ContractID = 0;
                }
                else
                {
                    ContractID = contract.ContractID;
                }
                abzHash.ContractID = ContractID;
                hashRepo.UpdateHash(abzHash);
            }
            else
            {
                if ((SelectedContractId > 0) && ((int)abzHash.ContractID != SelectedContractId))
                {
                    abzHash.ContractID = SelectedContractId;
                    hashRepo.UpdateHash(abzHash);
                }
            }
            contract = repo.GetContract((int)abzHash.CustID);
            if (contract == null)
            {
                ContractID = 0;
            }
            else
            {
                ContractID = contract.ContractID;
            }

            Cust cust = db.Custs.Find((int)abzHash.CustID);

            contracts            = repo.GetContracts((int)abzHash.CustID);
            ViewData["Contract"] = new SelectList(contracts, "ContractID", "Num", ContractID);

            IEnumerable <OrgView> orgView = repo.GetCust(usr);

            ViewData["Cust"] = new SelectList(orgView, "ID", "Txt", abzHash.CustID);
            ViewBag.MenuItem = "recv";
            ViewBag.User     = usr;


            BalanceRepository bl = new BalanceRepository();

            ViewBag.customer  = cust.SmalName;
            ViewBag.balance   = bl.GetBalance(CustID, (int)abzHash.ContractID).ToString();
            ViewBag.contractn = "";
            Contract contractcc = db.Contracts.Find((int)abzHash.ContractID);

            if (contractcc != null)
            {
                ViewBag.contractn = "Договор № " + contractcc.Num;
            }

            SetCookie("custid", CustID.ToString());
            SetCookie("contractid", abzHash.ContractID.ToString());
            SetCookie("customer", ViewBag.customer);
            SetCookie("balance", ViewBag.balance);
            SetCookie("contract", ViewBag.contractn);



            return(View("Index", cust));
        }
Exemplo n.º 16
0
 public BalanceBusiness()
 {
     balanceRepository = new BalanceRepository();
 }
        public void Setup()
        {
            var context = DatabaseHelper.Connection();

            _repository = new BalanceRepository(context);
        }