public AddTradeWindowViewModel(ITransactionService transactionService, IStaticReferences staticReferences, Fund fund)
 {
     AddTradeCommand     = new AddTradeCommand(this, transactionService);
     _transactionService = transactionService;
     _fund             = fund;
     _staticReferences = staticReferences;
     _lastLockedDate   = _staticReferences.GetMostRecentLockedDate(fund.FundId);
     _validationErrors = new ValidationErrors();
     _validationErrors.ErrorsChanged += ChangedErrorsEvents;
     _tradeDate      = DateExtentions.InitialDate();
     _settleDate     = DateExtentions.InitialDate();
     _custodian      = cmbCustodians[0];
     _securitiesList = _staticReferences.GetAllSecurities();
 }
Exemplo n.º 2
0
        //[Authorize(Policy = "Trade.Add")]
        public async Task <IActionResult> AddTradeAsync([FromBody] TradeViewModel tradeViewModel)
        {
            if (!IsModelStateValid())
            {
                return(Response());
            }

            var usersRequest = await GetUsersRequestAsync(HttpContext, tradeViewModel.UserGet.IdUserIdentity, tradeViewModel.UserLet.IdUserIdentity);

            if (usersRequest == null)
            {
                return(Response());
            }

            var domainModel = Mapper.Map <TradeModel>(tradeViewModel);

            domainModel.UserGet = usersRequest.ListUsersViewModel[0];
            domainModel.UserLet = usersRequest.ListUsersViewModel[1];

            var cmd = new AddTradeCommand(usersRequest.UserLoggedIn, domainModel);
            await _mediator.SendCommand(cmd);

            return(Response(cmd));
        }