public void Invoke(InvestmentPayRequest action) { var investment = _investmentService.Get(action.InvestmentId); if (investment == null) { throw new BusinessException(BusinessStatusCode.NotFound, "投资不存在。"); } if (investment.Status != Contracts.Enum.InvestmentStatus.Initial) { throw new BusinessException(BusinessStatusCode.Conflict, "投资已经支付。"); } Project project = _projectService.Get(investment.ProjectId); using (UnitOfWork u = new UnitOfWork(EventBus)) { CommandBus .Send(new CompleteInvestment(action.InvestmentId)) .Send(new ChangeProjectAmount(project.ProjectId, 0 - investment.Amount)) .Send(new ChangeAccountAmount(investment.AccountId, 0 - investment.Amount)) .Send(new ChangeAccountAmount(project.BorrowerId, investment.Amount)) .Send(new CreateAccountActivity(investment.AccountId, project.BorrowerId, investment.Amount)); u.Complete(); } }
public async Task<ActionResult> Pay(int id) { var action = new InvestmentPayRequest(id); ActionResponse response = await ActionBus.SendAsync<InvestmentActionBase, InvestmentPayRequest>(action); TempData["ActionResponse"] = response; return RedirectToAction("Index", new { id = action.InvestmentId }); }
public async Task <ActionResult> Pay(int id) { var action = new InvestmentPayRequest(id); ActionResponse response = await ActionBus.SendAsync <InvestmentActionBase, InvestmentPayRequest>(action); TempData["ActionResponse"] = response; return(RedirectToAction("Index", new { id = action.InvestmentId })); }
public async Task<ActionResult> Pay(int id) { var action = new InvestmentPayRequest { InvestmentId = id }; ActionResponse response = await ServiceLocator.ActionBus.SendAsync(action); TempData["ActionResponse"] = response; return RedirectToAction("Index", new { id = action.InvestmentId }); }
public async Task <ActionResult> Pay(int id) { var action = new InvestmentPayRequest { InvestmentId = id }; ActionResponse response = await ServiceLocator.ActionBus.SendAsync(action); TempData["ActionResponse"] = response; return(RedirectToAction("Index", new { id = action.InvestmentId })); }
public ActionResult Pay(int id) { var action = new InvestmentPayRequest(id); try { ActionStation.Invoke<InvestmentPayRequest>(action); } catch (BusinessException ex) { TempData["ActionResponse"] = ex.Message; } return RedirectToAction("Index", new { id = action.InvestmentId }); }
public ActionResult Pay(int id) { var action = new InvestmentPayRequest(id); try { ActionStation.Invoke <InvestmentPayRequest>(action); } catch (BusinessException ex) { TempData["ActionResponse"] = ex.Message; } return(RedirectToAction("Index", new { id = action.InvestmentId })); }