public ActionResult ManageInvest(int Id, InvestViewModel vm) { var user = Utils.LoadUserDataFromSession(); var kri = db.KRIInvests.Single(d => d.Id == Id); var kriParam = kri.KRIInvestParameters.Last(); var indicatorCode = "K" + Utils.GetSerialNumberTemplate() + ".I" + Id; var value = vm.KRIInvestData.Value; var nonInvest = new KRIInvestData { Value = value, UserId = user.UserId, CreatedAt = DateTime.Now, TransactionDate = vm.KRIInvestData.TransactionDate, Code = "", KRIInvestId = Id, Grade = Utils.GenerateKRIGrade(kriParam, value), Target = kriParam.Target ?? 0 }; db.KRIInvestDatas.Add(nonInvest); db.SaveChanges(); nonInvest.Code = indicatorCode + "." + nonInvest.Id; db.SaveChanges(); vm.KRIInvest = db.KRIInvests.Include("KRIInvestDatas.UserInfo").Single(d => d.Id == Id); vm.User = Utils.LoadUserDataFromSession(); return(View(vm)); }
public async Task <ActionResult> Create(InvestViewModel vm) { var action = new InvestmentCreateRequest(_sequenceService.Next(SequenceID.ACE_Investment, 1), vm.AccountId, vm.ProjectId, vm.Amount); var response = await ActionBus.SendAsyncWithRetry <InvestmentActionBase, InvestmentCreateRequest>(action, 3); TempData["ActionResponse"] = response; return(RedirectToAction("Index", new { id = action.InvestmentId })); }
public ActionResult Invest() { ViewBag.Title = "Invest"; var vm = new InvestViewModel { KRIInvests = db.KRIInvests.ToList() }; return(View(vm)); }
public ActionResult ManageInvest(int Id) { ViewBag.Title = "Invest"; var kri = db.KRIInvests.Single(d => d.Id == Id); var vm = new InvestViewModel { KRIInvest = kri, User = Utils.LoadUserDataFromSession() }; return(View(vm)); }
public ActionResult Create(InvestViewModel vm) { var action = new InvestmentCreateRequest(_sequenceService.Next(SequenceID.ACE_Investment, 1), vm.AccountId, vm.ProjectId, vm.Amount); try { ActionStation.Invoke <InvestmentCreateRequest>(action); } catch (BusinessException ex) { TempData["ActionResponse"] = ex.Message; } return(RedirectToAction("Index", new { id = action.InvestmentId })); }
public async Task <ActionResult> Create(InvestViewModel vm) { var action = new InvestmentCreateRequest { InvestmentId = _sequenceService.Next(SequenceID.ACE_Investment, 1), AccountId = vm.AccountId, ProjectId = vm.ProjectId, Amount = vm.Amount }; var response = await ServiceLocator.ActionBus.SendAsync(action); //var response = ServiceLocator.ActionBus.Send(action); TempData["ActionResponse"] = response; return(RedirectToAction("Index", new { id = action.InvestmentId })); }
public async Task <IActionResult> Invest(InvestViewModel model) { var user = await userManager.GetUserAsync(User); if (!ModelState.IsValid) { ModelState.AddModelError(string.Empty, "Error found while login in"); } var invest = mapper.Map <Investment>(model); invest.CustomerId = user.Id; uow.TransactionRepository.Add(invest); await uow.SaveAsync(); var product = uow.ProductRepository.GetAll(); ViewData["Products"] = new SelectList(product, "Id", "Name"); ViewBag.Success = "Your investment has been recorded successful"; ModelState.Clear(); return(View()); }
public InvestCryptoCommand(InvestViewModel investViewModel, IInvestService investService, IAccountStore accountStore) { _investViewModel = investViewModel; _investService = investService; _accountStore = accountStore; }
public SearchCurrencyCommand(InvestViewModel investViewModel, ICryptoPriceService cryptoPriceService) { _investViewModel = investViewModel; _cryptoPriceService = cryptoPriceService; }
public async Task <IActionResult> Invest(InvestViewModel model) { if (!_userService.IsSignedIn(User)) { return(RedirectToAction(nameof(HomeController.Index), "Home")); } var config = await _globalConfigurationService.GetValueConfig(Constants.Configuration.ProgramLocked); if (config.Contains("true")) { return(View("~/Views/Lock.cshtml")); } var currentUser = await _userService.GetCurrentUser(); if (currentUser.KVRR == null) { return(RedirectToAction(nameof(AccountController.MyPortfolio), "Account")); } if (!ModelState.IsValid) { return(View(model)); } if (model.TargetAmount <= _configuration.GetValue <decimal>("InvestmentValidation:MinInvestAmount")) { ModelState.AddModelError("TargetAmount", ValidationMessages.InvestInvalid); return(View(model)); } var orderModel = new OrderModel() { Desc = "Đầu tư Savenow", MerchantCode = _configuration.GetValue <string>("PaymentParam:merchant_code"), Msisdn = currentUser.PhoneNumber, TransAmount = model.TargetAmount.ToString(), Version = _configuration.GetValue <string>("PaymentParam:version") }; var order = await _orderService.SaveOrder(orderModel); if (!_configuration.GetValue <bool>("PaymentSecurity:DisableVTP")) { var check_sum = Helpers.CreateCheckSum(_configuration.GetValue <string>("PaymentSecurity:AccessCode"), _configuration.GetValue <string>("PaymentSecurity:SecretKey"), order.Id.ToString(), _configuration.GetValue <string>("PaymentParam:command"), order.MerchantCode, order.Id.ToString(), order.TransAmount, order.Version); var paymentLink = _configuration.GetValue <bool>("PaymentLink:IsLive") ? _configuration.GetValue <string>("PaymentLink:Live") : _configuration.GetValue <string>("PaymentLink:Test"); var paymentParameters = string.Format("billcode={0}&command={1}&desc={2}&merchant_code={3}&sender_msisdn={4}&order_id={5}&return_url={6}&cancel_url={7}&trans_amount={8}&version={9}&check_sum={10}", order.Id.ToString(), _configuration.GetValue <string>("PaymentParam:command"), "Dau tu SmartFunds", _configuration.GetValue <string>("PaymentParam:merchant_code"), currentUser.PhoneNumber, order.Id.ToString(), Url.Action(action: nameof(InvestmentController.DoPayment), controller: "Investment", values: null, protocol: Request.Scheme), Url.Action(action: nameof(InvestmentController.CancelPayment), controller: "Investment", values: null, protocol: Request.Scheme), model.TargetAmount, _configuration.GetValue <string>("PaymentParam:version"), check_sum); var logger = NLog.Web.NLogBuilder.ConfigureNLog("nlog.config").GetCurrentClassLogger(); logger.Info("Investment with ViettelPay: Call payment link: " + paymentLink + paymentParameters); return(Redirect(paymentLink + paymentParameters)); } else { await _fundTransactionHistoryService.Investment(decimal.Parse(order.TransAmount), currentUser.UserName, order.Id.ToString()); return(RedirectToAction(nameof(AccountController.PaymentResult), "Account")); } }