/// <summary> /// /// Set the default portfolio and add the everymatrix user id in the Gz user database table /// /// To be used during user registration /// /// </summary> /// <param name="customerId"></param> /// <param name="gmUserId"></param> /// <returns></returns> public void SetDbDefaultPorfolioAddGmUserId(int customerId, int gmUserId) { var user = db.Users.SingleOrDefault(x => x.Id == customerId); if (user == null) { throw new InvalidOperationException("User not found."); } if (user.IsRegistrationFinalized.HasValue && user.IsRegistrationFinalized.Value) { return; } var defaultPortfolioRisk = (confRepo.GetConfRow()).FIRST_PORTFOLIO_RISK_VAL; ConnRetryConf.TransactWithRetryStrategy( db, () => { // Fix Everymatrix User Id leak during registration if (!user.GmCustomerId.HasValue) { user.GmCustomerId = gmUserId; } SetDbDefaultPortfolio(customerId, defaultPortfolioRisk); user.IsRegistrationFinalized = true; }); }
/// <summary> /// /// Sell any vintages marked for selling. /// /// This method will update the vintages selling values before selling them. /// The vintages are sold at the current fund prices. /// /// </summary> /// <param name="customerId"></param> /// <param name="vintages"></param> /// <param name="gmailPwd"></param> /// <param name="sellOnThisYearMonth"></param> /// <param name="sendEmail2Admin"></param> /// <param name="queueAzureConnString"></param> /// <param name="queueName"></param> /// <param name="emailAdmins"></param> /// <param name="gmailUser"></param> /// <returns></returns> public ICollection <VintageDto> SaveDbSellAllSelectedVintagesInTransRetry( int customerId, ICollection <VintageDto> vintages, bool sendEmail2Admin, string queueAzureConnString, string queueName, string emailAdmins, string gmailUser, string gmailPwd, string sellOnThisYearMonth = "") { // Update market price on it.. they may have left the browser window open // for a long time before hitting withdraw var vintagesToBeSold = sellOnThisYearMonth.Length == 0 ? SetAllSelectedVintagesPresentMarketValue(customerId, vintages) : SetAllSelectedVintagesMarketValueOn(customerId, vintages, sellOnThisYearMonth); if (vintagesToBeSold > 0) { ConnRetryConf.TransactWithRetryStrategy(db, () => { SaveDbSellAllSelectedVintages(customerId, vintages, sellOnThisYearMonth); }); if (sendEmail2Admin) { var user = GetEmailVintageLiquidationUser(customerId); //https://stackoverflow.com/questions/29383116/asp-net-mvc-5-asynchronous-action-method Task.Run(() => SendVintageWithdrawalReq(user, customerId, vintages, queueAzureConnString, queueName, emailAdmins, gmailUser, gmailPwd) ); } } return(vintages); }