Пример #1
0
        private void BindFilter()
        {
            DateTime fromDate;

            if (!DateTime.TryParse(rFilter.GetUserValue("From Date"), out fromDate))
            {
                fromDate = DateTime.Today;
            }
            dtStartDate.Text        = fromDate.ToShortDateString();
            dtEndDate.Text          = rFilter.GetUserValue("To Date");
            txtFromAmount.Text      = rFilter.GetUserValue("From Amount");
            txtToAmount.Text        = rFilter.GetUserValue("To Amount");
            txtTransactionCode.Text = rFilter.GetUserValue("Transaction Code");

            ddlFundType.Items.Add(new ListItem(All.Text, All.Id.ToString()));

            var fundService = new FundService();

            foreach (Fund fund in fundService.Queryable())
            {
                ListItem li = new ListItem(fund.Name, fund.Id.ToString());
                li.Selected = fund.Id.ToString() == rFilter.GetUserValue("Fund");
                ddlFundType.Items.Add(li);
            }

            BindDefinedTypeDropdown(ddlCurrencyType, Rock.SystemGuid.DefinedType.FINANCIAL_CURRENCY_TYPE, "Currency Type");
            BindDefinedTypeDropdown(ddlCreditCardType, Rock.SystemGuid.DefinedType.FINANCIAL_CREDIT_CARD_TYPE, "Credit Card Type");
            BindDefinedTypeDropdown(ddlSourceType, Rock.SystemGuid.DefinedType.FINANCIAL_SOURCE_TYPE, "Source");
        }
Пример #2
0
        public void SetMarketValue_MultiplyPriceAndQuantity()
        {
            FundService fs    = new FundService();
            var         value = fs.SetMarketValue(10, 2);

            Assert.AreEqual(20, value);
        }
Пример #3
0
        public ResultDTO FundManualAdjust(FundManualAdjustFormDTO form)
        {
            var fundService = new FundService(db);

            fundService.ManualAdjust(UserId, form.userId, form.balanceTypeId, form.amount);

            return(new ResultDTO(true));
        }
Пример #4
0
        public ResultDTO WithdrawalCancel(int withdrawalId)
        {
            var fundService = new FundService(db);

            fundService.CancelWithdrawal(UserId, withdrawalId);

            return(new ResultDTO(true));
        }
Пример #5
0
        public void SetStockWeight_DivideMVAndTotalSumOfAllMV()
        {
            FundService fs = new FundService();
            var         mv = fs.SetMarketValue(10, 1);
            var         sw = fs.SetStockWeight(mv, 10);

            Assert.AreEqual(1, sw);
        }
Пример #6
0
        public void SetTransactionCost_MultiplyMVandBondValue()
        {
            FundService fs    = new FundService();
            var         mv    = fs.SetMarketValue(10, 2);
            var         value = fs.SetTransactionCost(mv, Type.Bond);

            Assert.AreEqual(0.4, value);
        }
Пример #7
0
        public void SetTotalMarketValue_IfListIsEmptyReturnPriceMultiplyByQuantity()
        {
            var         funds       = new BindingList <Fund>();
            Operations  operations  = new Operations();
            FundService fundService = new FundService();

            var value = operations.SetTotalMarketValue(funds, fundService.SetMarketValue(10, 1));

            Assert.AreEqual(10, value);
        }
Пример #8
0
        public MainPage()
        {
            InitializeComponent();

            //Remover navigation bar
            NavigationPage.SetHasNavigationBar(this, false);

            fundService = new FundService();
            funds       = new ObservableCollection <Fund>();

            lstFunds.ItemsSource = funds;

            GetAllFunds();
        }
Пример #9
0
        public bool THTDeposit(THTDepositFormDTO form)
        {
            var authorization = Request.Headers.Authorization;

            if (authorization?.Parameter == null || authorization.Parameter != YJYGlobal.CALLBACK_AUTH_TOKEN)
            {
                throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.Unauthorized,
                                                                            "invalid auth token"));
            }

            if (string.IsNullOrWhiteSpace(form.transactionHash) || string.IsNullOrWhiteSpace(form.from) ||
                string.IsNullOrWhiteSpace(form.tokenAmount))
            {
                throw new ArgumentOutOfRangeException(nameof(form));
            }

            form.tokenAmount     = form.tokenAmount.Trim();
            form.transactionHash = form.transactionHash.Trim();
            form.from            = form.from.Trim();
            form.to = form.to.Trim();

            BigInteger bi;
            var        tryParse = BigInteger.TryParse(form.tokenAmount, NumberStyles.None, null, out bi);

            if (!tryParse || bi < new BigInteger(0))
            {
                throw new ArgumentOutOfRangeException(nameof(form.tokenAmount));
            }

            var deposit = FundService.AddTHTDeposit(form.transactionHash, form.@from, form.to, form.tokenAmount);

            if (deposit == null)
            {
                return(false);
            }

            try
            {
                var fundService = new FundService(db);
                fundService.AddUserBalanceByTHTDeposit(deposit.Id);
            }
            catch (Exception e)
            {
                YJYGlobal.LogExceptionAsWarning(e);
            }

            return(true);
        }
Пример #10
0
        public void UpdateStockWeight_TakeAllEntriesAndUpdateStockWeight()
        {
            var         funds       = new BindingList <Fund>();
            Operations  operations  = new Operations();
            Market      market      = new Market(1);
            FundService fundService = new FundService();

            funds.Add(new Fund(1, Type.Bond, "Bond 1", 12, 1, 12, 0.24, 100));
            funds.Add(new Fund(1, Type.Bond, "Bond 1", 12, 1, 12, 0.24, 100));
            funds.Add(new Fund(1, Type.Bond, "Bond 1", 12, 1, 12, 0.24, 100));
            funds.Add(new Fund(1, Type.Bond, "Bond 1", 12, 1, 12, 0.24, 100));
            market.TotalMarketValue = operations.SetTotalMarketValue(funds, 1);
            operations.UpdateStockWeight(funds, market);
            Assert.AreNotEqual(100, funds[0].StockWeight);
            Assert.AreEqual(25, funds[1].StockWeight);
            Assert.AreEqual(25, funds[2].StockWeight);
            Assert.AreEqual(25, funds[3].StockWeight);
        }
Пример #11
0
        private async void ShowData()
        {
            lblFundName.Text = this.name;
            double totalValue = 0;

            FundService fundService = new FundService();
            var         response    = await fundService.GetByName(name);

            fundsHistory.Clear();

            foreach (var item in response)
            {
                totalValue += item.Price;
                fundsHistory.Add(item);
            }

            lblTotal.Text = $"R$ {totalValue}";
        }
Пример #12
0
        public ResultDTO SetTHTAddress(THTAddressFormDTO form)
        {
            if (string.IsNullOrWhiteSpace(form.address) || form.address == YJYGlobal.THT_COMPANY_ADDRESS)
            {
                throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "invalid address"));
            }

            try
            {
                var fundService = new FundService(db);
                fundService.SetTHTAddress(UserId, form.address);
            }
            catch (ArgumentException)
            {
                throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, Resources.Resource.THTAddressExisted));
            }

            return(new ResultDTO(true));
        }
Пример #13
0
        public ResultDTO NewTHTWithdrawal(NewTHTWithdrawalFormDTO form)
        {
            if (form.amount > 10000000)
            {
                throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest,
                                                                            "invalid amount"));
            }

            var fundService  = new FundService(db);
            var withdrawalId = fundService.NewTHTWithdrawal(UserId, form.amount);

            var withdrawal = db.THTWithdrawals.FirstOrDefault(o => o.Id == withdrawalId);

            var balanceType = db.BalanceTypes.FirstOrDefault(o => o.Id == withdrawal.BalanceTypeId);

            var request =
                WebRequest.CreateHttp(YJYGlobal.THT_BC_API_HOST + "refund?type=" + balanceType.Code.ToLower() + "&id=" +
                                      withdrawal.Id + "&to=" + withdrawal.To + "&value=" + withdrawal.Value);

            request.Method = "GET";
            request.Headers.Add("Authorization", "Bearer " + YJYGlobal.CALLBACK_AUTH_TOKEN);

            withdrawal.SendAt = DateTime.UtcNow;
            try
            {
                var response       = request.GetResponse() as HttpWebResponse;
                var responseStream = response.GetResponseStream();
                var sr             = new StreamReader(responseStream);
                var str            = sr.ReadToEnd();

                withdrawal.SendResult = response.StatusCode.ToString();
            }
            catch (Exception e)
            {
                withdrawal.SendResult = e.Message.TruncateMax(500);
            }
            db.SaveChanges();

            return(new ResultDTO(true));
        }
Пример #14
0
        /// <summary>
        /// Handles the filter display for each saved user value
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The e.</param>
        /// <exception cref="System.NotImplementedException"></exception>
        protected void rFilter_DisplayFilterValue(object sender, Rock.Web.UI.Controls.GridFilter.DisplayFilterValueArgs e)
        {
            switch (e.Key)
            {
            case "Fund":

                int fundId = 0;
                if (int.TryParse(e.Value, out fundId))
                {
                    var service = new FundService();
                    var fund    = service.Get(fundId);
                    if (fund != null)
                    {
                        e.Value = fund.Name;
                    }
                }

                break;

            case "Currency Type":
            case "Credit Card Type":
            case "Source":

                int definedValueId = 0;
                if (int.TryParse(e.Value, out definedValueId))
                {
                    var definedValue = DefinedValueCache.Read(definedValueId);
                    if (definedValue != null)
                    {
                        e.Value = definedValue.Name;
                    }
                }

                break;
            }
        }
Пример #15
0
        private void BindFilter()
        {
            DateTime fromDate;
            if ( !DateTime.TryParse( rFilter.GetUserValue( "From Date" ), out fromDate ) )
            {
                fromDate = DateTime.Today;
            }
            dtStartDate.Text = fromDate.ToShortDateString();
            dtEndDate.Text = rFilter.GetUserValue( "To Date" );
            txtFromAmount.Text = rFilter.GetUserValue( "From Amount" );
            txtToAmount.Text = rFilter.GetUserValue( "To Amount" );
            txtTransactionCode.Text = rFilter.GetUserValue( "Transaction Code" );

            ddlFundType.Items.Add( new ListItem( All.Text, All.Id.ToString() ) );

            var fundService = new FundService();
            foreach ( Fund fund in fundService.Queryable() )
            {
                ListItem li = new ListItem( fund.Name, fund.Id.ToString() );
                li.Selected = fund.Id.ToString() == rFilter.GetUserValue( "Fund" );
                ddlFundType.Items.Add( li );
            }

            BindDefinedTypeDropdown( ddlCurrencyType, Rock.SystemGuid.DefinedType.FINANCIAL_CURRENCY_TYPE, "Currency Type" );
            BindDefinedTypeDropdown( ddlCreditCardType, Rock.SystemGuid.DefinedType.FINANCIAL_CREDIT_CARD_TYPE, "Credit Card Type" );
            BindDefinedTypeDropdown( ddlSourceType, Rock.SystemGuid.DefinedType.FINANCIAL_SOURCE_TYPE, "Source" );
        }
Пример #16
0
        /// <summary>
        /// Handles the filter display for each saved user value
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The e.</param>
        /// <exception cref="System.NotImplementedException"></exception>
        protected void rFilter_DisplayFilterValue( object sender, Rock.Web.UI.Controls.GridFilter.DisplayFilterValueArgs e )
        {
            switch ( e.Key )
            {
                case "Fund":

                    int fundId = 0;
                    if ( int.TryParse( e.Value, out fundId ) )
                    {
                        var service = new FundService();
                        var fund = service.Get( fundId );
                        if ( fund != null )
                        {
                            e.Value = fund.Name;
                        }
                    }

                    break;

                case "Currency Type":
                case "Credit Card Type":
                case "Source":

                    int definedValueId = 0;
                    if ( int.TryParse( e.Value, out definedValueId ) )
                    {
                        var definedValue = DefinedValueCache.Read( definedValueId );
                        if ( definedValue != null )
                        {
                            e.Value = definedValue.Name;
                        }
                    }

                    break;
            }
        }
 public async Task <IActionResult> GetAllFunds()
 {
     return(Ok(await FundService.GetAllFunds()));
 }