public void FundViewModel_can_be_converted_from_an_issue_entity_implicitly() { // Arrange Issue issue = new Issue() { Id = 1, AuthorID = "AuthId", Author = Mock.Of <ApplicationUser>(), CreatedAt = DateTime.Now, FundingGoal = 50000.00, FundingRaised = 0.00, IsFundable = true, IsStateIssue = true, IsVotableIssue = true, LongDescription = "Long", ShortDescription = "Short", StateAbbrev = "MO", Title = "Title", UpdatedAt = null, VoteCountNeeded = 15000, Votes = new List <Vote>() }; // Act FundViewModel fundVm = issue; // Assert Assert.AreEqual(issue.Id, fundVm.Id); Assert.AreEqual(issue.Title, fundVm.Title); Assert.AreEqual(issue.ShortDescription, fundVm.ShortDescription); Assert.AreEqual(issue.FundingGoal, fundVm.FundingGoal); Assert.AreEqual(issue.FundingRaised, fundVm.FundingRaised); }
public void ConstructorShouldGetFundFromFundFactory() { var fundFactoryMock = MockRepository.GenerateMock <IFundFactory>(); FundViewModel fundViewModel = new FundViewModel(fundFactoryMock); fundFactoryMock.AssertWasCalled(factory => factory.GetFund()); }
public JsonResult Search(FundViewModel model) { JSonResult objResult = new JSonResult(); try { List <MFund> entList = new List <MFund>(); entList = new WebApiFund().GetFunds(); model.FundCode = model.FundCode ?? ""; model.Description = model.Description ?? ""; if (!model.FundCode.Equals("")) { entList = entList.Where(p => p.FundCode == model.FundCode).ToList(); } if (!model.Description.Equals("")) { entList = entList.Where(p => p.Description == model.Description).ToList(); } objResult.data = entList; } catch (Exception) { objResult.data = null; objResult.isError = true; objResult.message = string.Format(MessageResource.ControllerGetExceptionMessage, "Fund"); } return(Json(objResult)); }
public MainWindow() { InitializeComponent(); // TODO: move preferences load to repository via bootstrapper var preferences = JsonConvert.DeserializeObject <dynamic>(File.ReadAllText("Artifacts/validationRules.json")); var validator = new StockValidator(); IEnumerable <dynamic> validations = preferences.validations; foreach (var validation in validations) { StockSerializer.DeserializeValidator(validator, validation); } var observers = new List <IStockObserver>() { new StockNameObserver(new[] { "StockTypeQuantity" }), new StockMarketValueObserver(new [] { "Price", "Quantity" }), new StockTransactionCostsObserver(new[] { "MarketValue", "StockType" }, new Dictionary <string, decimal>() { { "Bond", 0.5m }, { "Equity", 0.3m } }), new StockWeightObserver(new[] { "TotalMarketValue" }) }; DataContext = new FundViewModel(validator, observers); }
public FundViewModel GetFundInformation(string accountCode, string customerCode = null, Currency currency = null) { List <FundInformation> results = _portfolioManager.GetFundInformation(customerCode, accountCode, currency); FundInformation fund = results.First(); FundViewModel result = Mapper.Map <FundInformation, FundViewModel>(fund); List <OptionPositionViewModel> positions = GetOptionPositions(customerCode, accountCode); decimal floatingPL = 0; foreach (OptionPositionViewModel position in positions) { floatingPL += position.OptionFloatingPL; } result.FloatingPL = floatingPL; RiskLevelInformation riskLevel = _portfolioManager.GetAccountRiskLevelInformation(accountCode, currency); result.UsedMargin = riskLevel.UsedMargin; result.MarginRate = 0; if (fund.AvailableFund != 0) { result.MarginRate = riskLevel.UsedMargin / fund.AvailableFund; } return(result); }
public IActionResult Fund([FromBody] FundViewModel viewmodel) { if (viewmodel == null) { return(BadRequest()); } var fundingOptions = new FundProjectOptions() { FundingPackageId = int.Parse(viewmodel.FundingPackageId), ProjectId = int.Parse(viewmodel.ProjectId) }; _projectService.FundProject(fundingOptions); var projectFunded = _projectService.GetById(int.Parse(viewmodel.ProjectId)); var funder = _userService.GetById(User.GetUsername()); _userBackerService.Add(new UserBacker(projectFunded.ProjectId, funder.Id)); _basicService.Complete(); return(Ok()); }
public ActionResult Index() { ////暫時測試用 //Session["CartID"] = "11-27-2017 12:26_未登錄"; if (Session["CartID"] != null) { var shoppingcart = from cart in cart.GetAll() where cart.CartID == Session["CartID"].ToString() && cart.IsOrdered == false select new CartTable { RecordID = cart.RecordID, FundName = cart.FundGoods.FundMaster.FundName, FundCpyName = cart.FundGoods.FundCompany.FundCpyName, FundTypeName = cart.FundGoods.FundType.FundTypeName, StarRank = cart.FundGoods.FundMaster.StarRank, NetValue = cart.FundGoods.FundMaster.FundDetail.OrderByDescending(x => x.Date).Select(x => x.NetValue).FirstOrDefault(), Date = cart.FundGoods.FundMaster.FundDetail.OrderByDescending(x => x.Date).Select(x => x.Date).FirstOrDefault(), FundCurrencyCode = cart.FundGoods.FundCurrencyCode }; FundViewModel fundVM = new FundViewModel(); fundVM.CartTable = shoppingcart; return(View(fundVM)); } else { return(Content("<script>alert('請先進行購物');window.location='" + Url.Action("Index", "FundOverview", new { area = "Fund" }) + "'</script>")); } }
//暫時 //[AllowAnonymous] public ActionResult UpdateTradeCode() { if (Session["CartID"] == null) { return(RedirectToAction("Index", "FundOverview")); } FundViewModel fundVM = new FundViewModel(); var shoppingcart = from cart in cart.GetAll() where cart.CartID == Session["CartID"].ToString() && cart.IsOrdered == false //暫時寫死 //where cart.CartID == "XXX" select new CartTable { RecordID = cart.RecordID, FundName = cart.FundGoods.FundMaster.FundName, FundCpyName = cart.FundGoods.FundCompany.FundCpyName, FundTypeName = cart.FundGoods.FundType.FundTypeName, StarRank = cart.FundGoods.FundMaster.StarRank, NetValue = cart.FundGoods.FundMaster.FundDetail.OrderByDescending(x => x.Date).Select(x => x.NetValue).FirstOrDefault(), Date = cart.FundGoods.FundMaster.FundDetail.OrderByDescending(x => x.Date).Select(x => x.Date).FirstOrDefault(), FundCurrencyCode = cart.FundGoods.FundCurrencyCode, }; var fundTradeType = from type in tradeType.GetAll() select type; fundVM.CartTable = shoppingcart; fundVM.FundTradeType = fundTradeType; return(View(fundVM)); }
public void SetBondState_SetColorForGreen() { DI.Register(); FundViewModel viewModel = new FundViewModel(); viewModel.AddBond("bond 1", 10, 100); Assert.AreEqual(0, viewModel.Funds[0].State); }
public void SetEquityState_SetColorGreen0() { DI.Register(); FundViewModel viewModel = new FundViewModel(); viewModel.AddEquity("equity 1", 10, 1000000); Assert.AreEqual(0, viewModel.Funds[0].State); }
public void AddEquity_AddsNewEquityToGrid() { DI.Register(); FundViewModel viewModel = new FundViewModel(); viewModel.AddEquity("Equity 1", 12, 1); Assert.AreEqual("Equity 1", viewModel.Funds[0].Name); Assert.AreEqual(1, viewModel.Funds.Count); }
public void AddBond_AddsNewBonToGrid() { DI.Register(); FundViewModel viewModel = new FundViewModel(); viewModel.AddBond("Bond 1", 12, 1); Assert.AreEqual("Bond 1", viewModel.Funds[0].Name); Assert.AreEqual(1, viewModel.Funds.Count); }
public BudgetingPage(FundViewModel fundView, ExpenseViewModel expenseView) { var expenseStore = new SQLiteExpenseStore(DependencyService.Get <ISQLiteDb>()); var fundStore = new SQLiteFundStore(DependencyService.Get <ISQLiteDb>()); var pageService = new PageService(); ViewModel = new BudgetViewModel(pageService, fundView ?? new FundViewModel(), fundStore, expenseView ?? new ExpenseViewModel(), expenseStore); InitializeComponent(); }
public FundsListPage(FundViewModel fundView) { Constants.myAdID = "ca-app-pub-6838059012127071/2942523886"; var fundStore = new SQLiteFundStore(DependencyService.Get <ISQLiteDb>()); var pageService = new PageService(); ViewModel = new BudgetViewModel(pageService, fundView, fundStore); InitializeComponent(); }
private IActionResult GetFundsByManager(string name) { _logger.LogInformation($"GetFundsByManager called with {name}"); var funds = _fundsRepo.GetAll(); var filteredByManager = funds .Where(f => f.Name == name) .Select(f => FundViewModel.FromFundDetails(f)); return(this.Ok(filteredByManager)); }
public FundViewModel GetFund() { FundViewModel result = _portfolioOrchestrator.GetFundInformation( FCIdentity.CustomerAccountCode, FCIdentity.CustomerCode, Currency.ChineseYuan); return(result); }
public AddFundPage(FundViewModel fundView) { Constants.myAdID = "ca-app-pub-6838059012127071/1659262181"; InitializeComponent(); var pageService = new PageService(); var fundStore = new SQLiteFundStore(DependencyService.Get <ISQLiteDb>()); Title = (fundView.Id == 0) ? "New Fund" : "Edit Fund"; BindingContext = new FundDetailViewModel(fundView ?? new FundViewModel(), fundStore, pageService); }
public void AddStockUpdatesCollectionWithTheAddedStock() { var fund = new FundFactory().Create(); fund.Add(new Bond(10.0m, 5)); var sut = new FundViewModel(fund); var oldCount = sut.Stocks.Cast <StockViewModel>().Count(); sut.AddStock(new StockInputModel("15,0", "5", "Bond")); Assert.AreEqual(oldCount + 1, sut.Stocks.Cast <StockViewModel>().Count()); }
public void UpdateSummaryTable_UpdateTableAfterAddingEntry() { DI.Register(); FundViewModel viewModel = new FundViewModel(); viewModel.AddBond("Bond 1", 10, 10); viewModel.UpdateSummaryTable(); Assert.AreEqual( viewModel.FundSummary.SingleOrDefault(x => x.Type == Type.Total)._TotalMv, 100); }
public MainWindow() { InitializeComponent(); IFundFactory fundFactory = new FundFactory(); _fundViewModel = new FundViewModel(fundFactory); xFundAddPanel.DataContext = _fundViewModel; xFundGridPanel.DataContext = _fundViewModel; xFundSummaryPanel.DataContext = _fundViewModel; }
public ActionResult MyProject() { if (Session["user"] == null) { return(RedirectToAction("Index", "Home")); } else { if ((Session["user"] as User).IsInvestor == false) { UserManager um = new UserManager(); int Ses_id = (Session["user"] as User).Id; ProjectManager pm = new ProjectManager(); var Projects = pm.List(x => x.user.Id == Ses_id); List <FundViewModel> fvm = new List <FundViewModel>(); foreach (var item in Projects) { fvm.Add(new FundViewModel() { Id = item.Id, ProjectAmount = item.ProjectAmount, ProjectDate = item.ProjectDuration, ProjectName = item.ProjectName, ProjectTitle = item.ProjectTitle }); } return(View((fvm))); } else { List <FundViewModel> fundModel = new List <FundViewModel>(); ProjectManager pm = new ProjectManager(); UserManager um = new UserManager(); int sessionId = (Session["user"] as User).Id; FundManager fm = new FundManager(); List <Fund> funds = fm.List(x => x.user_Investor.Id == sessionId); List <Project> projects = new List <Project>(); foreach (Fund element in funds) { FundViewModel fvm = new FundViewModel(); Project p = pm.Find(x => x.Id == element.Project.Id); fvm.ProjectAmount = element.Amount; fvm.ProjectDate = element.Date; fvm.ProjectName = p.ProjectName; fvm.ProjectTitle = p.ProjectTitle; fvm.Id = p.Id; fundModel.Add(fvm); } return(View(fundModel)); } } }
private IActionResult GetFundByCode(string code) { _logger.LogInformation($"GetFundByCode called with {code}"); var funds = _fundsRepo.GetAll(); var fund = funds.SingleOrDefault(x => x.MarketCode == code); if (fund == null) { return(this.NotFound()); } return(this.Ok(FundViewModel.FromFundDetails(fund))); }
public async Task <ActionResult> Fund(string flowId) { var(flow, _) = await GetFlow(flowId); var vm = new FundViewModel { PayPalClientId = _payPalService.ClientId, FlowId = flowId, Amount = flow.Amount }; return(View(vm)); }
public void UpdateFundSummary_UpdateSummaryTableFirstTime() { Operations operations = new Operations(); DI.Register(); var fundViewModel = new FundViewModel(); var funds = new BindingList <Fund>(); var market = new Market(1); funds.Add(new Fund(1, Type.Bond, "Bond 1", 12, 1, 12, 0.24, 100)); operations.UpdateFundSummary(fundViewModel.FundSummary, funds, market); Assert.AreEqual( fundViewModel.FundSummary.SingleOrDefault(x => x.Type == Type.Bond)._TotalNumber, 1); }
public IActionResult Edit([Bind("Name", "FundId", "Minimum", "Goal")] FundViewModel model) { if (ModelState.IsValid) { var thisFund = _db.Funds.FirstOrDefault(funds => funds.FundId == model.FundId); thisFund.Name = model.Name; _db.Entry(thisFund).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); } { return(View()); } }
public void SetBindingData(MarketDataVM vmQuoteViewModel, PositionViewModel longPosition, PositionViewModel shortPosition, FundViewModel vmFundViewModel) { mQuoteViewModel = vmQuoteViewModel; mLPositionViewModel = longPosition; mSPositionViewModel = shortPosition; mFundViewModel = vmFundViewModel; FundGrid.DataContext = mFundViewModel; /// TBD /// //for example by Lucas QuoteGrid.DataContext = mQuoteViewModel; }
public void FundViewModel_GetPrettyFundingPercentage_returns_correct_value_when_210_raised() { // Arrange FundViewModel vm = new FundViewModel() { FundingRaised = 210, FundingGoal = 100 }; // Act string result = vm.GetPrettyFundingPercentage(); // Assert Assert.AreEqual("210", result); }
public void FundViewModel_GetPrettyFundingPercentage_returns_valid_percent_when_half_raised() { // Arrange FundViewModel vm = new FundViewModel() { FundingRaised = 25000, FundingGoal = 50000 }; // Act string result = vm.GetPrettyFundingPercentage(); // Assert Assert.AreEqual("50", result); }
public void FundIssue_Get_maps_the_found_issue_to_the_vm() { // Arrange var issue = Mock.Of <Issue>(i => i.Id == 3 && i.Title == "Test Title" && i.ShortDescription == "Short Desc"); _repo.Setup(r => r.Find(3)).Returns(issue); controller = new IssuesController(_repo.Object); FundViewModel issueVm = issue; // Act var result = controller.FundIssue(3) as ViewResult; // Assert result.Model.ShouldDeepEqual(issueVm); }
private void Button_Click(object sender, RoutedEventArgs e) { Button b = sender as Button; string symbol = b.CommandParameter.ToString(); QuoteViewModel quote = null; foreach (QuoteViewModel view in MainWindow.MyInstance.MktDataHandler.Quotes) { if (view.Symbol == symbol) { quote = view; break; } } PositionViewModel longPosition = null; PositionViewModel shortPosition = null; foreach (PositionViewModel view in MainWindow.MyInstance.TrdHandler.Positions) { if (view.RawData.InstrumentID == symbol) { if (view.RawData.PosiDirection == "2") { longPosition = view; } else { shortPosition = view; } } } FundViewModel fund = MainWindow.MyInstance.TrdHandler.Fund; //to load advanced order window AdvancedMakeOrderWin win = new AdvancedMakeOrderWin(); win.SetBindingData(quote, longPosition, shortPosition, fund); win.Show(); }