Ejemplo n.º 1
0
        public void GetTransaction()
        {
            const string accountName  = "Test Account 1";
            const string categoryName = "Test Category 1";
            const byte   categoryType = 1;
            var          service      = new MoneyService();
            var          userService  = new UserService();
            var          userId1      = userService.Register("testUser1" + Guid.NewGuid(), "testPassword");

            service.CreateAccount(userId1, accountName, 1);
            var accounts1 = service.GetAllAccounts(userId1);

            service.CreateCategory(userId1, categoryName, categoryType);
            var categories = service.GetAllCategories(userId1);

            service.Deposit(userId1, accounts1[0].Id, DateTime.Now, 25, 10, "Some income comment", categories[0].Id);

            var transactions = service.GetAllTransactions(userId1, accounts1[0].Id);

            Assert.Equal(1, transactions.Count);

            var transaction = service.GetTransaction(userId1, accounts1[0].Id, transactions[0].TransactionId);

            Assert.NotNull(transaction);
            Assert.Equal(2, transaction.Postings.Count);

            Assert.NotNull(transaction.Category);
            Assert.Equal(categoryName, transaction.Category.Name);
            Assert.Equal(categoryType, transaction.Category.CategoryType);

            Assert.NotNull(transaction.Postings[0].Account);
            Assert.Equal(accountName, transaction.Postings[0].Account.Name);
        }
Ejemplo n.º 2
0
        static int ScriptDelete2()
        {
            var money = MoneyService.Read(new Money()
            {
                Currency = "RUB", Amount = 1000, WorkerMoney = 1
            }, 1, 0).First();

            // Предполагается, что действия до создания модели - это моделирование выбора пользователя

            var models = OrdersService.Read(new Orders()
            {
                MoneyId = money.Id
            });

            DateTime startTime = DateTime.Now;

            foreach (var model in models)
            {
                OrdersService.Delete(model);
            }
            DateTime finishTime = DateTime.Now;

            return((int)(finishTime - startTime).TotalMilliseconds);


            /*Money model = new Money() { Currency = "RUB", Amount = 1000, WorkerMoney = 1 };
             *
             * DateTime startTime = DateTime.Now;
             * MoneyService.Delete(model);
             * DateTime finishTime = DateTime.Now;
             *
             * return (int)(finishTime - startTime).TotalMilliseconds;*/
        }
Ejemplo n.º 3
0
        public void UpdateTransaction()
        {
            var userService = new UserService();
            var service     = new MoneyService();
            var userId      = userService.Register("testUser1" + Guid.NewGuid(), "testPassword");

            service.CreateAccount(userId, "Test Account 1", 1);
            var accounts = service.GetAllAccounts(userId);

            service.CreateCategory(userId, "Test Category 1", 1);
            var categories = service.GetAllCategories(userId);

            service.Deposit(userId, accounts[0].Id, DateTime.Now, 25, 10, "Some income comment", null);
            service.Withdrawal(userId, accounts[0].Id, DateTime.Now, 10, 5, "Some expense comment", categories[0].Id);

            var balance = service.GetAccountBalance(userId, accounts[0].Id);

            Assert.Equal(200, balance);

            var transactionRecords = service.GetAllTransactions(userId, accounts[0].Id);
            var transactionId      = transactionRecords[0].TransactionId;

            Assert.NotNull(transactionRecords);
            Assert.Equal(2, transactionRecords.Count);

            service.UpdateTransaction(transactionId, userId, accounts[0].Id, DateTime.Now, 32, 20, "Updated income", categories[0].Id, false);

            balance = service.GetAccountBalance(userId, accounts[0].Id);
            Assert.Equal(-690, balance);
        }
Ejemplo n.º 4
0
        private void button_Click(object sender, RoutedEventArgs e)
        {
            var customer = new Customer
            {
                Name      = textBoxCustomerName.Text,
                Telephone = textBoxCustomerPhone.Text
            };

            var creditCard = new CreditCard
            {
                CardNumber  = textBoxCreditCard.Text,
                Cvc         = textBoxSecurityCode.Text,
                ExpireyDate = DateTime.Parse(textBoxExpireyDate.Text),
            };

            bool success = MoneyService.Charge(customer, creditCard, decimal.Parse(textBoxAmount.Text));

            if (success)
            {
                SmsService.SendSms("+18184348962", "Payment Successful");
                MessageBox.Show("Payment Successful");
            }
            else
            {
                SmsService.SendSms("+18184348962", "Payment Unsuccessful");
                MessageBox.Show("Payment Unsuccessful");
            }
        }
Ejemplo n.º 5
0
        public void Initialize()
        {
            GameObjectsManager.Initialize();
            ImageManager.Initialize();
            TimeManager.Initialize();

            SaveLoadService = new SaveLoadService();
            SaveLoadService.Initialize();

            ConfigurationService = new ConfigurationService();
            ConfigurationService.Initialize();
            BuyPriceDictionaryService = new BuyPriceDictionaryService();
            BuyPriceDictionaryService.Initialize();
            SellPriceDictionaryService = new SellPriceDictionaryService();
            SellPriceDictionaryService.Initialize();
            // before trade need to know a price
            TradeService = new TradeService();
            TradeService.Initialize();
            MoneyService = new MoneyService();
            MoneyService.Initialize();
            ProducerProductionDictionaryService = new ProducerProductionDictionaryService();
            ProducerProductionDictionaryService.Initialize();
            //
            ProductionDurationDictionaryService = new ProductionDurationDictionaryService();
            ProductionDurationDictionaryService.Initialize();
            SatietyDurationDictionaryService = new SatietyDurationDictionaryService();
            SatietyDurationDictionaryService.Initialize();
            // before visualize money amount need to know a money amount
            InventoryService = new InventoryService();
            InventoryService.Initialize();
            // before visualize inventory items amount need to know a inventory items amount
            UserInterfaceManager.Initialize();
        }
Ejemplo n.º 6
0
        public MoneyController()
        {
            var UnitOfWork = new EFUnitOfWork();

            _MoneyService = new MoneyService(UnitOfWork);
            _LogService   = new LogService(UnitOfWork);
        }
Ejemplo n.º 7
0
        public void GetAllAssetTypes()
        {
            var service = new MoneyService();

            var assets = service.GetAllAssetTypes();

            Assert.Equal(4, assets.Count);
        }
Ejemplo n.º 8
0
        public PayController()
        {
            servicePay      = new PayService(db);
            serviceOrder    = new OrderService(db);
            serviceRecharge = new RechargeService(db);
            serviceUser     = new UserService(db);
            serviceMoney    = new MoneyService(db);

            userTicket = new UserTicketDetailService(db);
        }
Ejemplo n.º 9
0
 //实例化
 public OrderController()
 {
     serviceOrder     = new OrderService(db);
     serviceDetail    = new OrderDetailService(db);
     serviceRoom      = new RoomService(db);
     serviceMoney     = new MoneyService(db);
     serviceFlow      = new FlowService(db);
     serviceDiscount  = new DiscountService(db);
     servicePay       = new PayService(db);
     UserTicketDetail = new UserTicketDetailService(db);
 }
Ejemplo n.º 10
0
        static void Main(string[] args)
        {
            CreditCardService   creditCardService   = new CreditCardService();
            MoneyService        moneyService        = new MoneyService();
            BuisnessCardService buisnessCardService = new BuisnessCardService();

            creditCardService.GetCreditCard();
            moneyService.GetMoney();
            buisnessCardService.GetBuisnessCard();

            Console.ReadKey();
        }
Ejemplo n.º 11
0
        static int ScriptUpdate2()
        {
            Money model = MoneyService.Read(new Money()
            {
                Currency = "RUB", Amount = 1000, WorkerMoney = 1
            }, 1, 0).First();
            DateTime startTime = DateTime.Now;

            MoneyService.Update(model);
            DateTime finishTime = DateTime.Now;

            return((int)(finishTime - startTime).TotalMilliseconds);
        }
Ejemplo n.º 12
0
        static int ScriptInsert2()
        {
            Money model = new Money()
            {
                Currency = "RUB", Amount = 1000, WorkerMoney = 1
            };

            DateTime startTime = DateTime.Now;

            MoneyService.Create(model);
            DateTime finishTime = DateTime.Now;

            return((int)(finishTime - startTime).TotalMilliseconds);
        }
Ejemplo n.º 13
0
        public static IEnumerable <MoneyViewModel> GetFakeData()
        {
            var moneyService = new MoneyService();
            var query        = from d in moneyService.GetAll()
                               select new MoneyViewModel
            {
                Category    = (MoneyCategory)d.Categoryyy,
                Total       = d.Amounttt,
                Date        = d.Dateee,
                Description = d.Remarkkk
            };

            return(query);
        }
Ejemplo n.º 14
0
        public ServiceAccess(Current.GetTicket getTicket, Current.GetUrl getUrl)
        {
            var repos = new Repos(getUrl);

            BaseMove = new BaseMoveSaverService(this, repos);

            Safe   = new SafeService(this, repos);
            Admin  = new AdminService(this, repos);
            Money  = new MoneyService(this, repos);
            Robot  = new RobotService(this, repos);
            Report = new ReportService(this, repos);

            Current = new Current(Safe, getTicket);
        }
Ejemplo n.º 15
0
        public void Withdrawal()
        {
            var service     = new MoneyService();
            var userService = new UserService();
            var userId      = userService.Register("testUser" + Guid.NewGuid(), "testPassword");

            service.CreateAccount(userId, "Test Account", 1);
            var accounts = service.GetAllAccounts(userId);

            service.CreateCategory(userId, "Test Category", 1);
            var categories = service.GetAllCategories(userId);

            service.Withdrawal(userId, accounts[0].Id, DateTime.Now, 13, 10, "Some expense comment", categories[0].Id);
        }
Ejemplo n.º 16
0
        public void Transfer()
        {
            var service     = new MoneyService();
            var userService = new UserService();
            var userId1     = userService.Register("testUser1" + Guid.NewGuid(), "testPassword");
            var userId2     = userService.Register("testUser2" + Guid.NewGuid(), "testPassword");

            service.CreateAccount(userId1, "Test Account 1", 1);
            service.CreateAccount(userId2, "Test Account 2", 1);
            var accounts1 = service.GetAllAccounts(userId1);
            var accounts2 = service.GetAllAccounts(userId2);

            service.Transfer(userId1, accounts1[0].Id, userId2, accounts2[0].Id, DateTime.Now, 78, "Some transfer comment");
        }
Ejemplo n.º 17
0
        public void Deposit()
        {
            var service     = new MoneyService();
            var userService = new UserService();
            var userId      = userService.Register("testUser" + Guid.NewGuid(), "testPassword");

            service.CreateAccount(userId, "Test Account", 1);
            var accounts = service.GetAllAccounts(userId);

            service.CreateCategory(userId, "Test Category", 1);
            var categories = service.GetAllCategories(userId);

            service.Deposit(userId, accounts[0].Id, DateTime.Now, 25, 2, "Some income comment", categories[0].Id);
        }
Ejemplo n.º 18
0
        public void CreateAccount()
        {
            const string expectedAccountName = "Test Account";
            var          userService         = new UserService();
            var          service             = new MoneyService();
            var          userId = userService.Register("testUser" + Guid.NewGuid(), "testPassword");

            int accountId = service.CreateAccount(userId, expectedAccountName, 1);

            var accounts = service.GetAllAccounts(userId);

            Assert.Equal(1, accounts.Count);
            Assert.Equal(expectedAccountName, accounts[0].Name);
        }
Ejemplo n.º 19
0
        public void DeleteCategory()
        {
            var userService = new UserService();
            var service     = new MoneyService();
            var userId      = userService.Register("testUser" + Guid.NewGuid(), "testPassword");

            service.CreateCategory(userId, "Test Category", 1);
            var categories = service.GetAllCategories(userId);

            service.DeleteCategory(userId, categories[0].Id);

            categories = service.GetAllCategories(userId);
            Assert.Equal(0, categories.Count);
        }
Ejemplo n.º 20
0
        public void DeleteAccount()
        {
            const string accountName = "Test Account";
            var          userService = new UserService();
            var          service     = new MoneyService();
            var          userId      = userService.Register("testUser" + Guid.NewGuid(), "testPassword");

            service.CreateAccount(userId, accountName, 1);
            var accounts = service.GetAllAccounts(userId);

            service.DeleteAccount(userId, accounts[0].Id);

            accounts = service.GetAllAccounts(userId);
            Assert.Equal(0, accounts.Count);
        }
        public MoneyController()
        {
            _mSvc = new MoneyService();

            //預先取得類別的下拉選單
            _CateList = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Text  = "",
                    Value = ""
                }
            };
            _CateList.AddRange(_mSvc.EnumToSelectList <CategoryState>());
        }
Ejemplo n.º 22
0
        public List <MyMoneyViewModel> GetData()
        {
            MoneyService moneyService = new MoneyService();

            var dbQuery = (from data in moneyService.Lookup()
                           select new MyMoneyViewModel
            {
                Dateee = data.Dateee,
                Amounttt = data.Amounttt,
                Remarkkk = data.Remarkkk,
                Categoryyy = data.Categoryyy,
            });

            return(dbQuery.ToList());
        }
Ejemplo n.º 23
0
        static int ScriptRead1()
        {
            Money model = MoneyService.Read(new Money()
            {
                Currency = "RUB", Amount = 1000, WorkerMoney = 1
            }, 1, 0).First();

            DateTime startTime  = DateTime.Now;
            Money    models     = MoneyService.Read(model, 1, 0).First();
            DateTime finishTime = DateTime.Now;

            Console.WriteLine("{0}: {1} - {2}", models.Id, models.Currency, models.Amount);

            return((int)(finishTime - startTime).TotalMilliseconds);
        }
Ejemplo n.º 24
0
        public void GetAllCategories()
        {
            const string expectedCategoryName    = "Test Category";
            const byte   expectedNewCategoryType = 1;
            var          userService             = new UserService();
            var          service = new MoneyService();
            var          userId  = userService.Register("testUser" + Guid.NewGuid(), "testPassword");

            service.CreateCategory(userId, expectedCategoryName, expectedNewCategoryType);

            var categories = service.GetAllCategories(userId);

            Assert.Equal(1, categories.Count);
            Assert.Equal(expectedCategoryName, categories[0].Name);
            Assert.Equal(expectedNewCategoryType, categories[0].CategoryType);
        }
Ejemplo n.º 25
0
        public void OnClientEvent(Client client, string eventName, params object[] arguments)         //arguments param can contain multiple params
        {
            switch (eventName)
            {
            case "KeyboardKey_E_Pressed":
                if (!client.isInVehicle)
                {
                    if (client.hasData("player"))
                    {
                        ATM atm = ATMService.ATMList.FirstOrDefault(x => x.Position.DistanceTo(client.position) <= 1);
                        if (atm != null)
                        {
                            OpenATM(client);
                            API.sendChatMessageToPlayer(client, "ATM with ID: ~y~" + atm.Id + " ~w~found");
                        }
                    }
                }
                break;

            case "ATM_Withdraw":
                if (MoneyService.HasPlayerEnoughBank(client, Convert.ToDouble(arguments[0])))
                {
                    MoneyService.WithdrawMoney(client, Convert.ToDouble(arguments[0]));
                    API.sendNotificationToPlayer(client, "~g~" + arguments[0] + " $~w~ was withdrawn from the account.");
                    API.triggerClientEvent(client, "ATM_CloseMenu");
                }
                else
                {
                    API.sendNotificationToPlayer(client, "~r~You don't have enough money on your account.");
                }
                break;

            case "ATM_Deposit":
                if (MoneyService.HasPlayerEnoughCash(client, Convert.ToDouble(arguments[0])))
                {
                    MoneyService.DepositMoney(client, Convert.ToDouble(arguments[0]));
                    API.sendNotificationToPlayer(client, "There were ~g~" + arguments[0] + " $~w~ added to your account.");
                    API.triggerClientEvent(client, "ATM_CloseMenu");
                }
                else
                {
                    API.sendNotificationToPlayer(client, "~r~You don't have enough money at your wallet.");
                }
                break;
            }
        }
Ejemplo n.º 26
0
        void _runPreinit()
        {
            string      systemPath_  = HostingEnvironment.MapPath(@"~");
            InitService initService_ =
                __singleton <InitService> ._instance();

            initService_._runPreinit();

            AccountService accountService_ =
                __singleton <AccountService> ._instance();

            accountService_._runPreinit();

            MoneyService moneyService_ =
                __singleton <MoneyService> ._instance();

            moneyService_._runPreinit();
        }
Ejemplo n.º 27
0
        public void UpdateAccount()
        {
            const string accountName            = "Test Account";
            const string expectedNewAccountName = "Renamed Account";
            const int    assetType            = 1;
            const int    expectedNewAssetType = 2;
            var          userService          = new UserService();
            var          service = new MoneyService();
            var          userId  = userService.Register("testUser" + Guid.NewGuid(), "testPassword");

            service.CreateAccount(userId, accountName, assetType);
            var accounts = service.GetAllAccounts(userId);

            service.UpdateAccount(userId, accounts[0].Id, expectedNewAccountName, expectedNewAssetType);

            accounts = service.GetAllAccounts(userId);
            Assert.Equal(1, accounts.Count);
            Assert.Equal(expectedNewAccountName, accounts[0].Name);
            Assert.Equal(expectedNewAssetType, accounts[0].AssetType.Id);
        }
Ejemplo n.º 28
0
        public void GetAccountBalance()
        {
            var service     = new MoneyService();
            var userService = new UserService();
            var userId1     = userService.Register("testUser1" + Guid.NewGuid(), "testPassword");
            var userId2     = userService.Register("testUser2" + Guid.NewGuid(), "testPassword");

            service.CreateAccount(userId1, "Test Account 1", 1);
            service.CreateAccount(userId2, "Test Account 2", 1);
            var accounts1 = service.GetAllAccounts(userId1);
            var accounts2 = service.GetAllAccounts(userId2);

            service.CreateCategory(userId1, "Test Category 1", 1);
            var categories1 = service.GetAllCategories(userId1);

            service.Deposit(userId1, accounts1[0].Id, DateTime.Now, 25, 10, "Some income comment", null);

            var balance = service.GetAccountBalance(userId1, accounts1[0].Id);

            Assert.Equal(250, balance);

            service.Withdrawal(userId1, accounts1[0].Id, DateTime.Now, 10, 5, "Some expense comment", categories1[0].Id);

            balance = service.GetAccountBalance(userId1, accounts1[0].Id);
            Assert.Equal(200, balance);

            balance = service.GetAccountBalance(userId2, accounts2[0].Id);
            Assert.Equal(0, balance);

            service.Transfer(userId1, accounts1[0].Id, userId2, accounts2[0].Id, DateTime.Now, 75, "Some transfer comment");

            balance = service.GetAccountBalance(userId1, accounts1[0].Id);
            Assert.Equal(125, balance);

            balance = service.GetAccountBalance(userId2, accounts2[0].Id);
            Assert.Equal(75, balance);
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AdminServiceTests"/> class.
        /// </summary>
        public AdminServiceTests()
        {
            Dispose();

            adminService = new AdminService
            {
                DefaultFolder = DefaultFolder
            };
            moneyService = new MoneyService
            {
                DefaultFolder = DefaultFolder
            };

            string login = "******" + Guid.NewGuid();

            moneyService.UserName = login;

            registrationService = new RegistrationService
            {
                DefaultFolder = DefaultFolder
            };

            currentUser = registrationService.Register(login, "testPassword");
        }
Ejemplo n.º 30
0
        public HomeController()
        {
            var unitOfWork = new EFUnitOfWork();

            _MoneyService = new MoneyService(unitOfWork);
        }