//普通实现方法 public static void Demo2() { IService s1 = new Saving(); IService s2 = new Draw(); IService s3 = new Fund(); //要办理业务的三个客户队列 List<IService> list = new List<IService>(); list.Add(s1); list.Add(s2); list.Add(s3); foreach (IService item in list) { if (item is Saving) { Console.WriteLine("存款"); } else if (item is Draw) { Console.WriteLine("取款"); } else if (item is Fund) { Console.WriteLine("基金"); } } }
public static void Demo(String[] args) { IService s1 = new Saving(); IService s2 = new Draw(); IService s3 = new Fund(); Visitor visitor = new Visitor(); s1.Accept(visitor); s2.Accept(visitor); s3.Accept(visitor); }
public async Task <Fund> DeleteFund(int id) { using (PortfolioAceDbContext context = _contextFactory.CreateDbContext()) { Fund fund = await context.Funds.FindAsync(id); if (fund == null) { return(fund); } context.Funds.Remove(fund); await context.SaveChangesAsync(); return(fund); } }
public ActionResult Create(Fund fund) { if (fund.CurrencyCode == null) { ModelState.AddModelError("", "Please select currency"); } if (ModelState.IsValid) { GetExRatesFromRequest(fund); db.Funds.AddObject(fund); db.SaveChanges(); return(RedirectToAction("Index")); } FetchViewbagItems(fund); return(View(fund)); }
public async Task <Fund> Run() { DateTime now = DateTime.Now.Date; IRepository <Fund> fundRepo = this.unitOfWork.GetRepository <Fund>(); IRepository <BudgetPeriod> periodRepo = this.unitOfWork.GetRepository <BudgetPeriod>(); Fund rootFund = await fundRepo.GetAll() .SingleAsync(f => f.UserId == this.userId && !f.ParentFundId.HasValue); IQuerySet <BudgetPeriod> usersBudgetPeriods = periodRepo.GetAll().Include(p => p.RootBudget) .Where(p => p.RootBudget.FundId == rootFund.Id); BudgetPeriod currentPeriod = await BudgetPeriodQueryUtils.GetForDate(usersBudgetPeriods, this.date); rootFund = await this.budgetLoader.LoadFundTree(rootFund, currentPeriod); return(rootFund); }
public void ReportViewModel_AddedStock_UpdatesBothTypeAndFundSummaryCorrectly(StockType type) { // Arrange var model = new Fund(); var reportVm = new ReportViewModel(model); // Act model.Stocks.Add(new Stock(type, 1m, 1, model.GenerateNextStockName(type))); // Assert Assert.Equal(1m, reportVm.FundTotalMarketValue); Assert.Equal(1, reportVm.FundTotalNumber); Assert.Equal(1m, reportVm.FundTotalStockWeight); Assert.Equal(1m, type == StockType.Equity ? reportVm.EquitiesTotalMarketValue : reportVm.BondsTotalMarketValue); Assert.Equal(1, type == StockType.Equity ? reportVm.EquitiesTotalNumber : reportVm.BondsTotalNumber); Assert.Equal(1m, type == StockType.Equity ? reportVm.EquitiesTotalStockWeight : reportVm.BondsTotalStockWeight); }
public void CreateFundCommandExecute_InsereFundoNaListaVazia_VerificaQueListaTem1Elemento_ComMock() { //Arrange MockCRUD mockcrud = new MockCRUD(); Fund fundo = new Fund("Nome", "Setor", "Tipo"); //Mock mockcrud.RetornoFundoCriado = fundo; mockcrud.RetornoFundoCriado.Id = 20; mockcrud.RetornoListaBD = new ObservableCollection <IFinancialProduct>(); MainWindowViewModel MWVM = new MainWindowViewModel(mockcrud); //Act (MWVM.CreateFundCommand).Execute(fundo); //Assert Assert.IsTrue(MWVM.ProdutoFinVM.FinancialProducts.Count == 1); }
public void CreateCommandExecute_InsereFundoEEleEstaNaListaComId_ComMock() { //Arrange MockCRUD mockcrud = new MockCRUD(); Fund fundo = new Fund(); //Mock mockcrud.RetornoFundoCriado = fundo; mockcrud.RetornoFundoCriado.Id = 20; mockcrud.RetornoListaBD = new ObservableCollection <IFinancialProduct>(); MainWindowViewModel MWVM = new MainWindowViewModel(mockcrud); //Act (MWVM.CreateFundCommand).Execute(null); //Parâmetro de .Execute não é utilizado. //Assert Assert.IsTrue(MWVM.ProdutoFinVM.FinancialProducts.Contains(mockcrud.RetornoFundoCriado)); }
protected void btnAdd_Click(object sender, EventArgs e) { if (txtAddFunds.Text.Contains(".") && txtAddFunds.Text != "") { if (txtAddFunds.Text.Contains("qwertyuiop[]\asdfghjkl;'zxcvbnm,/_~`!@#$%^&*()+")) { Response.Write(@"<script langauge='text/javascript'>alert ('You can only enter numbers with a period in between');</script>"); return; } else { Fund fund = new Fund(); double amount = 0; double.TryParse(txtAddFunds.Text, out amount); fund.Amount = amount; fund.Email = email; JavaScriptSerializer js = new JavaScriptSerializer(); String jsonCustomer = js.Serialize(fund); WebRequest request = WebRequest.Create(webApiUrl + "FundAccount/" + MerchantAccountID + "/" + APIKey); request.Method = "PUT"; request.ContentType = "application/json"; StreamWriter writer = new StreamWriter(request.GetRequestStream()); writer.Write(jsonCustomer); writer.Flush(); writer.Close(); WebResponse response = request.GetResponse(); Stream theDataStream = response.GetResponseStream(); StreamReader reader = new StreamReader(theDataStream); String data = reader.ReadToEnd(); reader.Close(); response.Close(); string Balance = validate.GetUserBalance(email); lblBalance.Text = Balance; txtAddFunds.Text = ""; } } else { Response.Write(@"<script langauge='text/javascript'>alert ('You must enter some amount before adding to your account');</script>"); return; } }
public void AddBond_PositiveTest_Equity() { //Arrange var price = 200M; var quantity = 1M; var builderFactory = A.Fake <IBuilderFactory>(); var stockRepository = A.Fake <IStockRepository>(); var fund = new Fund(builderFactory, stockRepository); //Act fund.AddBond(price, quantity); //Assert A.CallTo(stockRepository) .Where(call => call.Method.Name == "AddStock") .MustHaveHappened(Repeated.Exactly.Once); }
public void AddFundToList_FundoVaziaEInserida_ComMock() { //Arrange MockCRUD mockCRUD = new MockCRUD(); mockCRUD.RetornaBooleanoParaReturnDoAdd = true; mockCRUD.RetornoListaBD = new ObservableCollection <IFinancialProduct>(); mockCRUD.RetornoFundoCriado = new Fund(1); // Suponho que o BD decide criar o fundo com Id 1 FinancialProductViewModel FPVM = new FinancialProductViewModel(mockCRUD); int resultadoEsperado = 1; Fund resultadoRetornado = null; //Act resultadoRetornado = FPVM.AddFundToList(); //Assert Assert.AreEqual(resultadoEsperado, resultadoRetornado.Id); }
public void WhenExecutingCalculate_ThenStockWeightValueIsCalculatedAndUpdated() { var equity = new Stock { Id = 1, Type = StockType.Equity, Price = 100m, Quantity = 100m }; var bond = new Stock { Id = 2, Type = StockType.Bond, Price = 300m, Quantity = 100m }; var fund = new Fund { Stocks = new[] { equity, bond } }; equity.StockWeight.Calculate(fund); bond.StockWeight.Calculate(fund); Assert.AreEqual(0.25, equity.StockWeight?.Value); Assert.AreEqual(0.75, bond.StockWeight?.Value); }
public async Task ValidateConnectingFund_decimalMismatch() { //deploy a fund instance, but do no tests, that's something for the fund test suite Fund _FundContract; _FundContract = await Fund.New(_contract.ContractAddress, RpcClient); //make new price index but with other decimals // Deploy our test contract Meadow.Core.EthTypes.UInt256 fiatDecimals2 = 5; PriceIndex _contract2 = await PriceIndex.New(initPrice, "meadowInit", 4, (byte)fiatDecimals2, "BTC", "USD", RpcClient); //connect fund var txParams = new TransactionParams { From = Accounts[0] }; // admin await _contract2.connectFund(_FundContract.ContractAddress).SendTransaction(txParams); }
public FundsControllerTest() { serviceMock = new Mock <IFundsService>(); mapperMock = new Mock <IMapper>(); _controller = new FundsController(serviceMock.Object, mapperMock.Object); fundReponseNotFound = new FundResponse("Fund not found"); fund = new Fund { Id = 1, Name = "Fund1", Description = "Description fund 1" }; fundResource = new FundsResource { Id = 1, Name = "Fund1", Description = "Description fund 1" }; saveFundResource = new SaveFundsResource { Name = "Fund1", Description = "Description fund 1" }; id = 1L; }
public async Task <Fund> Update(Fund fund) { try { if (fund == null) { throw new InvalidParameterException(); } _unitOfWork.FundRepository.Update(fund); await _unitOfWork.SaveChangesAsync(); return(fund); } catch (Exception ex) { throw ex; } }
public AjaxResult PutFund([FromBody] Fund newFund) { var ajaxresult = new AjaxResult(); try { using (FundBL fundBL = new FundBL()) { fundBL.EditFundBL(newFund); } } catch (Exception ex) { ajaxresult.Success = false; ajaxresult.Data = ex; ajaxresult.Message = Resources.ErrorEditFund; } return(ajaxresult); }
public void FundEquals_FundsWithSameIdAreEqual_True() { //Arrange var fund1 = new Fund { FundId = 1 }; var fund2 = new Fund { FundId = 1 }; //Act //Assert Assert.AreEqual(fund1, fund2); }
public Fund GetFund() { var fund = new Fund { Stocks = this.fund.Select(stock => new Stock { Id = stock.Id, Name = stock.Name, Price = stock.Price, Quantity = stock.Quantity, Type = stock.Type, TransactionCost = stock.TransactionCost, Tolerance = stock.Tolerance }).ToArray() }; fund.Stocks.AsParallel().ForAll(stock => stock.StockWeight.Calculate(fund)); return(fund); }
public InvestorActionViewModel(ITransferAgencyService investorService, IStaticReferences staticReferences, Fund fund) { // if _isNavFinal. disable the price and quantity box, which means amount is entered manually this._investorService = investorService; this._fund = fund; _staticReferences = staticReferences; _tradeDate = DateExtentions.InitialDate(); _settleDate = DateExtentions.InitialDate(); _lastLockedDate = _staticReferences.GetMostRecentLockedDate(fund.FundId); _isNavFinal = false; _TAType = cmbIssueType[0]; // this defaults the type to subscription.. _validationErrors = new ValidationErrors(); _validationErrors.ErrorsChanged += ChangedErrorsEvents; // currency should be the funds base currency AddSubscriptionCommand = new AddSubscriptionCommand(this, investorService); AddRedemptionCommand = new AddRedemptionCommand(this, investorService); SelectedInvestorChangedCommand = new ActionCommand(ChangeInvestorHoldingCommand); }
private static void AddFund(int icustomerID, int ifundID, string ifundName) { Console.WriteLine("Before adding a fund to a customer name, the fund list"); //Get the list of Funds for given customer GetFunds(icustomerID); Console.WriteLine($"Adding a new fund for customer ID - {icustomerID} ... "); Fund newFund = CreateFund(ifundID, ifundName, icustomerID); fundcontext.Funds.Add(newFund); fundcontext.SaveChanges(); Console.WriteLine("After adding a fund to a customer name, the fund list"); //Get the list of Funds for given customer GetFunds(icustomerID); }
public void FundAdjustTotal_AdjustsTotal_True() { //Arrange Category testCategory = new Category { CategoryId = 5, Name = "Income" }; Fund testFund = new Fund { FundId = 5, Name = "General", Total = 2.99m }; Transaction testTransaction = new Transaction { TransactionId = 5, Description = "Paycheck", Type = "Deposit", Date = new DateTime(2018, 03, 01), Amount = 523.72m, CategoryId = 5, FundId = 5 }; //Act testFund.AdjustTotal(testTransaction); //Assert Assert.AreEqual(testFund.Total, 526.71m); }
public async Task Handle(BalanceInitializeIntegrationEvent @event) { var account = new Account(@event.Username); var existingFunds = await _fundRepository.GetByAccount(account); foreach (var asset in @event.Assets) { var matchFund = existingFunds.Where(f => f.Symbol.ToUpper() == asset.Symbol.ToUpper()).SingleOrDefault(); if (matchFund == null) { var fund = new Fund(new Account(@event.Username), asset.Symbol, asset.Total); this._fundRepository.Add(fund); await this._fundRepository.UnitOfWork.SaveEntitiesAsync(); } } }
public async Task <Fund> GetFundForOrganizationName(string OrganizationName) { var pushpayOrganizations = await _pushpay.GetOrganizations(); Fund fund = new Fund(); foreach (var item in pushpayOrganizations) { var key = item.Key; var funds = await _pushpay.GetFundsForOrganization(key); fund = funds.Items.Where(f => f.Name == OrganizationName).FirstOrDefault(); if (fund == null) { //create fund } } return(fund); }
private FundModel SerializeFund(Fund fund) { if (fund != null) { var result = new FundModel( fund.Id, fund.Name, fund.ShortName, fund.Ticker, fund.IssuerId, fund.SecurityType ); return(result); } else { return(null); } }
/// <summary> /// Creates a new fund and the intial budget. /// </summary> public async Task <Guid> Run() { IRepository <Budget> budgetRepo = this.unitOfWork.GetRepository <Budget>(); IRepository <Fund> fundRepo = this.unitOfWork.GetRepository <Fund>(); Budget parentBudget = await budgetRepo.GetAll().Include(b => b.Fund).SingleAsync(b => b.Id == this.parentBudgetId); parentBudget.Fund.HistoricalBudgets = new List <Budget>() { parentBudget }; Fund fund = new Fund(parentBudget.Fund, this.name, 0); Budget budget = new Budget(fund, parentBudget.BudgetPeriodId, this.setAmount); budgetRepo.Add(budget); await this.unitOfWork.SaveChangesAsync(); return(budget.Id); }
public ActionResult AddFund(Fund fund) { if (ModelState.IsValid) { //Customers Fund Increases into BanksCustomer Table BanksCustomer banksCustomer = db.BanksCustomers.Where(u => u.AccountNumber == fund.AccountNumber).FirstOrDefault(); LoginDetails updateFund = db2.LoginDetails.Where(u => u.AccountNumber1 == fund.AccountNumber).FirstOrDefault(); updateFund.Fund = banksCustomer.Fund + fund.Fund1; db2.Entry(updateFund).Property("Fund").IsModified = true; db2.SaveChanges(); //Save Funds History into Fund Table db.Funds.Add(fund); db.SaveChanges(); return(RedirectToAction("Index")); } return(View()); }
// GET: Funds/Edit/5 public ActionResult Edit(int?id) { if (Session["User"] == null) { return(RedirectToRoute("Default", new { Controller = "Home", Action = "Index" })); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Fund fund = db.Fund.Find(id); if (fund == null) { return(HttpNotFound()); } return(View(fund)); }
private void grd_bank_check_MouseDoubleClick(object sender, MouseButtonEventArgs e) { if (sender != null) { DataGrid grid = sender as DataGrid; if (grid != null && grid.SelectedItems != null && grid.SelectedItems.Count == 1) { try { Fund f = (Fund)grd_bank_check.SelectedItem; Guid ID = f.ID; // List<Check> ck = ak.Checks.Where(i => i.CBank == ID).ToList(); // var j = from q1 in // grd_bank_check.ItemsSource = ck.ToList(); var query = from cp in ak.CheckProcesses join c in ak.Checks on cp.IDCheck equals c.ID where cp.CPType == Guid.Empty /*|| cp.CPType != * Common.Constants.BaseInfoType.vosole_cheque*/ select new { c.ID, c.CNO, c.CAccountnumber, c.CPrice, c.CDescription, c.CDate, c.CName, c.CBank }; query = query.Where(x => x.CBank == ID); grd_bank_check.ItemsSource = query.ToList(); levels = 1; } catch { } } } }
public FundDetailViewModel(FundViewModel viewModel, IFundStore fundStore, IPageService pageService) { if (viewModel == null) { throw new ArgumentException(nameof(viewModel)); } _fundStore = fundStore; _pageService = pageService; SaveFundCommand = new Command(async() => await SaveFund()); Fund = new Fund { Id = viewModel.Id, Amount = viewModel.Amount, Source = viewModel.Source, LastUpdateDate = Convert.ToDateTime(Constants.phoneDate), UserId = Constants.curUserId }; }
public void Post([FromBody] Fund fund) { var fundsJson = System.IO.File.ReadAllText("data/Portfolio.json"); var funds = JsonConvert.DeserializeObject <List <Fund> >(fundsJson); if (!funds.Any()) { fund.FundId = 1; } else { var maxId = funds.Max(p => p.FundId); fund.FundId = maxId + 1; } funds.Add(fund); var serialized = JsonConvert.SerializeObject(funds); System.IO.File.WriteAllText("data/Fund.json", serialized); }
private void ProcessAccountBalance(string methodName, XmlNode node) { Guid accountID = XmlConvert.ToGuid(node.Attributes["AccountID"].Value); Guid currencyID = XmlConvert.ToGuid(node.Attributes["CurrencyID"].Value); if (methodName == "Modify" || methodName == "Add") { decimal balance = XmlConvert.ToDecimal(node.Attributes["Balance"].Value); if (Settings.SettingManager.Default.SystemParameter.EnableEmailNotify) { if (!AccountRepository.Default.Contains(accountID)) { return; } Account account = (Account)AccountRepository.Default.Get(accountID); Fund fund = (Fund)account.GetFund(currencyID); FaxEmailServices.FaxEmailEngine.Default.NotifyBalanceChanged(account, DateTime.Now, fund.CurrencyCode, balance); } } }
private List <Fund> PreperFunds(List <Fund> response) { List <Fund> groupFunds = new List <Fund>(); foreach (var item in response) { Fund currentFund = groupFunds.Where(f => f.Name.Equals(item.Name)).FirstOrDefault(); if (currentFund != null) { currentFund.Quantity += item.Quantity; currentFund.Price += item.Price; } else { groupFunds.Add(item); } } return(groupFunds); }
protected void buildConfirmationScreen(Person person) { HtmlGenericControl template = new HtmlGenericControl("script") { InnerHtml = "<table cellpadding=\"0\" cellspacing=\"0\" class=\"confirmationData\">{{#each info}}<tr><td class=\"label\">{{label}}</td><td class=\"data\">{{{data}}} </td></tr>{{/each}}</table>" }; template.Attributes.Add("type", "text/x-handlebars-template"); template.Attributes.Add("id", "datatable-template"); Page.Header.Controls.Add(template); StringBuilder confData = new StringBuilder(); confData.Append("var personData={ info: ["); confData.Append("{label:\"Name\",data:\"" + person.FullName + "\"},"); confData.Append("{label:\"Email Address\",data:\"" + person.Emails.FirstActive + "\"},"); confData.Append("{label:\"Phone\",data:\"" + person.Phones.FindByType(276) + "\"},"); confData.Append("{label:\"Address\",data:\"" + this.currentAddress.Address.StreetLine1 + "<br>" + this.currentAddress.Address.City + ", " + this.currentAddress.Address.State + "<br>" + this.currentAddress.Address.PostalCode + "\"},"); confData.Append("{label:\"Country\",data:\"" + this.currentAddress.Address.Country + "\"}"); confData.Append("]};"); confData.AppendLine(); confData.Append("var giftData={ info: ["); foreach (ContributionFund contribFund in this.SelectedFunds) { Fund curFund = new Fund(Convert.ToInt16(contribFund.FundId)); confData.Append("{label:\"" + curFund.OnlineName + "\",data:\"" + String.Format("{0:C}", contribFund.Amount) + "\"},"); } confData.Append("{label:\"\",data:\"\"},"); confData.Append("{label:\"Total\",data:\"" + String.Format("{0:C}", Convert.ToDecimal(hfTotalContribution.Value)).ToString() + "\"},"); confData.Append("{label:\"Memo\",data:\"" + tbComment.Text + "\"}"); confData.Append("]};"); confData.Append("var paymentData={ info: ["); confData.Append("{label:\"Payment Data\",data:\"" + rblPaymentMethod.SelectedItem.Text + "\"},"); confData.Append("{label:\"Account Number\",data:\"" + MaskAccountNumber(tbAccountNumber.Text) + MaskAccountNumber(tbCCNumber.Text) + "\"},"); if (tbRoutingNumber.Text.Length > 0) { confData.Append("{label:\"Bank Name\",data:\"" + tbBankName.Text + "\"},"); confData.Append("{label:\"Routing Number\",data:\"" + tbRoutingNumber.Text + "\"}"); } if (tbCCNumber.Text.Length > 0) { confData.Append("{label:\"Expiration Date\",data:\"" + ddlExpMonth.SelectedValue + "/" + ddlExpYear.SelectedValue + "\"}"); } confData.Append("]};"); HtmlGenericControl templateData = new HtmlGenericControl("script") { InnerHtml = confData.ToString() }; templateData.Attributes.Add("type", "text/javascript"); Page.Header.Controls.Add(templateData); return; }
protected void PopulateStaticControls() { for (int month = 1; month <= 12; month++) { ddlExpMonth.Items.Add(new ListItem(string.Format("{0:00}", month), month.ToString())); } for (int year = DateTime.Now.Year; year <= DateTime.Now.Year + 7; year++) { ddlExpYear.Items.Add(new ListItem(year.ToString(), year.ToString())); } ddlAccountType.Items.Add(new ListItem("Checking", "Checking")); ddlAccountType.Items.Add(new ListItem("Savings", "Savings")); ddlSelectedFund1.Items.Add(new ListItem()); ddlSelectedFund2.Items.Add(new ListItem()); ddlSelectedFund3.Items.Add(new ListItem()); string[] selectedFunds = this.FundListSetting.Split(',').Select(sValue => sValue.Trim()).ToArray(); foreach (string item in selectedFunds) { Fund curFund = new Fund(Convert.ToInt16(item)); ddlSelectedFund1.Items.Add(new ListItem(curFund.OnlineName,item)); ddlSelectedFund2.Items.Add(new ListItem(curFund.OnlineName, item)); ddlSelectedFund3.Items.Add(new ListItem(curFund.OnlineName, item)); this.AvailableFunds.Add(curFund); if (item == DefaultFund1Setting) { ddlSelectedFund1.SelectedValue = item; } if (item == DefaultFund2Setting) { ddlSelectedFund2.SelectedValue = item; } } }
public void Process(Fund service) { Console.WriteLine("基金"); // 基金 }