Пример #1
0
        public AuthenticationResponse GenerateOTP(string email, string password)
        {
            var OTP  = MathCalculations.GenerateRandomNo(6).ToString();
            var user = _unitOfWork.UserRepository.GetAll().Where(m => m.EmailID == email.Trim()).FirstOrDefault();

            if (user != null)
            {
                var isLogin = CommonFunction.ComparePassword(password, user.Password);
                if (isLogin)
                {
                    user.OTP = OTP;
                    _unitOfWork.UserRepository.Update(user);
                    var isSent = this.SendOTPEmail(user);
                    if (isSent)
                    {
                        return(new AuthenticationResponse {
                            Success = true, Message = CommonMessage.SentOTP
                        });
                    }
                }
            }
            return(new AuthenticationResponse {
                Message = ErrorMessage.Invalid_Credentials, Success = false
            });
        }
Пример #2
0
        public List <AccountStats> AddDummyAcountStats(string name)
        {
            var AccountStatsList = new List <AccountStats>();

            for (int i = 1; i <= 45; i++)
            {
                AccountStats accountStats = new AccountStats();

                accountStats.AccountId       = i.ToString();
                accountStats.StatringBalance = MathCalculations.GenerateRandomNo(6);
                accountStats.BestPL          = MathCalculations.GenerateRandomNo(4).ToString();
                accountStats.CreatedBy       = name;
                accountStats.Leverage        = i;
                accountStats.CreatedOn       = GenerateRandomDate();
                accountStats.DD         = MathCalculations.GenerateRandomNo(3);
                accountStats.NAV        = MathCalculations.GenerateRandomNo(3);
                accountStats.ROI        = MathCalculations.GenerateRandomNo(3);
                accountStats.SharpRatio = MathCalculations.GenerateRandomNo(6);
                accountStats.Status     = true;
                //accountStats.DD =  MathCalculations.GenerateRandomNo(2);
                accountStats.TimeLineId = i;
                accountStats.UpdatedBy  = MathCalculations.GenerateRandomNo(2);
                accountStats.UpdatedOn  = GenerateRandomDate();
                accountStats.WINRate    = MathCalculations.GenerateRandomNo(3);
                accountStats.WorstPL    = MathCalculations.GenerateRandomNo(2).ToString();

                //_unitOfWork.AccountStatsRepository.Add(accountStats);
                AccountStatsList.Add(accountStats);
            }

            return(AccountStatsList);
        }
Пример #3
0
        public static List <InstrumentStats> AddInstrumentStats(string name, List <TradeRecord> trades)
        {
            var instrumentName   = trades.Where(x => x.Cmd == TradeCommand.Buy || x.Cmd == TradeCommand.Sell).Select(x => x.Symbol).Distinct().ToList();
            var AccountStatsList = new List <InstrumentStats>();

            foreach (TimeLineEnum timeline in Enum.GetValues(typeof(TimeLineEnum)))
            {
                foreach (var item in instrumentName.Select((Value, Index) => new { Value, Index }))
                {
                    InstrumentStats instrumentStats = new InstrumentStats();
                    instrumentStats.TimeLineId     = (int)timeline;
                    instrumentStats.AccountStatsId = timeline;
                    instrumentStats.BuyRate        = MathCalculations.GenerateRandomNo(3);
                    instrumentStats.CreatedBy      = name;
                    //accountStats.CreatedOn = GenerateRandomDate();
                    instrumentStats.InstrumentId   = item.Index + 1;
                    instrumentStats.InstrumentName = item.Value;
                    instrumentStats.Volume         = InstrumentsCalculations.GetVolumeOfInstrumentByTimelineId((int)timeline, trades, item.Value);
                    instrumentStats.WINRate        = MathCalculations.GenerateRandomNo(2);
                    instrumentStats.NAV            = MathCalculations.GenerateRandomNo(2);
                    instrumentStats.ROI            = MathCalculations.GenerateRandomNo(2);
                    instrumentStats.Profit         = InstrumentsCalculations.GetProfitOfInstrumentByTimelineId((int)timeline, trades, item.Value);
                    instrumentStats.Loss           = InstrumentsCalculations.GetLossOfInstrumentByTimelineId((int)timeline, trades, item.Value);
                    instrumentStats.Status         = true;
                    if (instrumentStats.Volume > 0)
                    {
                        AccountStatsList.Add(instrumentStats);
                    }
                }
            }

            return(AccountStatsList);
        }
Пример #4
0
        public static List <AccountStats> AddAcountStats(List <TradeRecord> trades, int accountNumber, int leverage)
        {
            var dailyNavs        = unitOfWork.DailyNAVRepository.GetAll().Where(x => x.AccountNumber == accountNumber).FirstOrDefault();
            var AccountStatsList = new List <AccountStats>();

            for (int i = 1; i <= 44; i++)
            {
                AccountStats accountStats = new AccountStats();
                accountStats.AccountId  = i.ToString();
                accountStats.Balance    = MathCalculations.GenerateRandomNo(6);
                accountStats.BestPL     = CalculateBestPLForTimeline(i, trades);
                accountStats.CreatedBy  = MathCalculations.GenerateRandomNo(2);
                accountStats.Leverage   = leverage;
                accountStats.CreatedOn  = DateTime.UtcNow.ToString();
                accountStats.DD         = dailyNavs == null ? 0 : CalculateDDForTimeline(i, dailyNavs);
                accountStats.NAV        = dailyNavs == null ? 0 : CalculateNavForTimeline(i, dailyNavs); //Math.Round(dailyNavs.NAVByDate[dailyNavs.NAVByDate.Count - 1].NAV, 2);
                accountStats.ROI        = dailyNavs == null ? 0 : CalculateROIForTimeline(i, dailyNavs, trades);
                accountStats.SharpRatio = dailyNavs == null ? 0 : CalculateSharpRatioForTimeline(i, dailyNavs);
                accountStats.Status     = true;
                accountStats.TimeLineId = i;
                //accountStats.UpdatedBy = MathCalculations.GenerateRandomNo(2);
                //accountStats.UpdatedOn = GenerateRandomDate();
                accountStats.WINRate = CalculateWINForTimeline(i, trades);
                accountStats.WorstPL = CalculateWorstPLForTimeline(i, trades);

                //_unitOfWork.AccountStatsRepository.Add(accountStats);
                AccountStatsList.Add(accountStats);
            }

            return(AccountStatsList);
        }
Пример #5
0
 private static List <InstrumentStats> AddInstrumentStatsForExistingUsers(string name, List <TradeRecord> trades, List <InstrumentStats> Instruments)
 {
     try
     {
         var instrumentName      = trades.Where(x => x.Cmd == TradeCommand.Buy || x.Cmd == TradeCommand.Sell).Select(x => x.Symbol).Distinct().ToList();
         var existingInstruments = Instruments.Select(x => x.InstrumentName).Distinct().ToList();
         var newInstruments      = trades.Where(x => (x.Cmd == TradeCommand.Buy || x.Cmd == TradeCommand.Sell) && !existingInstruments.Contains(x.Symbol)).Select(x => x.Symbol).Distinct().ToList();
         var timelineIds         = GetTimelinesForExistingUser();
         foreach (var timeline in timelineIds)
         {
             foreach (var item in existingInstruments.Select((Value, Index) => new { Value, Index }))
             {
                 InstrumentStats existinInstrument = Instruments.Where(x => x.InstrumentName == item.Value && x.TimeLineId == (int)timeline).FirstOrDefault();
                 if (existinInstrument != null)
                 {
                     existinInstrument.Volume = InstrumentsCalculations.GetVolumeOfInstrumentByTimelineId((int)timeline, trades, item.Value);
                     existinInstrument.Profit = InstrumentsCalculations.GetProfitOfInstrumentByTimelineId((int)timeline, trades, item.Value);
                     existinInstrument.Loss   = InstrumentsCalculations.GetLossOfInstrumentByTimelineId((int)timeline, trades, item.Value);
                 }
             }
         }
         if (newInstruments.Count > 0)
         {
             foreach (TimeLineEnum timeline in Enum.GetValues(typeof(TimeLineEnum)))
             {
                 foreach (var item in newInstruments.Select((Value, Index) => new { Value, Index }))
                 {
                     InstrumentStats instrumentStats = new InstrumentStats();
                     instrumentStats.TimeLineId     = (int)timeline;
                     instrumentStats.AccountStatsId = timeline;
                     instrumentStats.BuyRate        = MathCalculations.GenerateRandomNo(3);
                     instrumentStats.CreatedBy      = name;
                     //accountStats.CreatedOn = GenerateRandomDate();
                     instrumentStats.InstrumentId   = item.Index + 1;
                     instrumentStats.InstrumentName = item.Value;
                     instrumentStats.Volume         = InstrumentsCalculations.GetVolumeOfInstrumentByTimelineId((int)timeline, trades, item.Value);
                     instrumentStats.WINRate        = MathCalculations.GenerateRandomNo(2);
                     instrumentStats.NAV            = MathCalculations.GenerateRandomNo(2);
                     instrumentStats.ROI            = MathCalculations.GenerateRandomNo(2);
                     instrumentStats.Profit         = InstrumentsCalculations.GetProfitOfInstrumentByTimelineId((int)timeline, trades, item.Value);
                     instrumentStats.Loss           = InstrumentsCalculations.GetLossOfInstrumentByTimelineId((int)timeline, trades, item.Value);
                     instrumentStats.Status         = true;
                     if (instrumentStats.Volume > 0)
                     {
                         Instruments.Add(instrumentStats);
                     }
                 }
             }
         }
         return(Instruments);
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Пример #6
0
        public List <InstrumentStats> AddInstrumentStats(string name)
        {
            var instrumentName = new List <string> {
                "EUR/USD", "GBP/SGD", "SGD/AUD"
            }.ToList();
            var timeLine = new List <int> {
                1, 2, 3
            }.ToList();

            var AccountStatsList = new List <InstrumentStats>();

            int count = 11;

            for (int i = 1; i <= 45; i++)
            {
                foreach (var item in instrumentName.Select((Value, Index) => new { Value, Index }))
                {
                    InstrumentStats accountStats = new InstrumentStats();

                    accountStats.AccountStatsId = i.ToString();
                    accountStats.BuyRate        = MathCalculations.GenerateRandomNo(3);
                    accountStats.CreatedBy      = name;
                    accountStats.CreatedOn      = GenerateRandomDate();
                    accountStats.InstrumentId   = item.Index + 1;
                    //InstrumentMasterEnum.EURUSD.ToString();
                    accountStats.Volume  = MathCalculations.GenerateRandomNo(2);
                    accountStats.WINRate = MathCalculations.GenerateRandomNo(2);
                    accountStats.NAV     = MathCalculations.GenerateRandomNo(2);
                    accountStats.ROI     = MathCalculations.GenerateRandomNo(2);
                    accountStats.Status  = false;

                    accountStats.TimeLineId = i;
                    accountStats.UpdatedBy  = name;
                    accountStats.UpdatedOn  = GenerateRandomDate();
                    AccountStatsList.Add(accountStats);

                    ++count;
                }
            }

            return(AccountStatsList);
        }
        public List <InvoiceModel> DownloadInvoice(string userId, List <Guid> invoiceIds)
        {
            var user = _unitOfWork.UserRepository.GetAll().Where(x => x.Id == ObjectId.Parse(userId)).FirstOrDefault();

            if (user != null)
            {
                if (user.UserInvoiceHistory == null)
                {
                    return(null);
                }

                var invoiceHistoryForInvoice = user.UserInvoiceHistory.Where(x => invoiceIds.Contains(x.Id)).ToList();
                //if (invoiceHistoryForInvoice == null || invoiceHistoryForInvoice.Count == 0) { return null; }
                var accounts = _unitOfWork.AccountDetailRepository.GetAll().Where(x => x.OrganizationId == user.OrganizationID).Count();

                List <InvoiceModel> invoiceModelList;
                invoiceModelList = invoiceHistoryForInvoice.Select(x => new InvoiceModel
                {
                    InvoiceNumber  = MathCalculations.GenerateRandomNo(8).ToString(),
                    Country        = user.Country,
                    EmailId        = user.EmailID,
                    InvoiceDate    = (DateTime.UtcNow).ToString("dd/MM/yyyy"),
                    ClientName     = user.Name,
                    PlanName       = x.PlanName,
                    PlanLogo       = x.PlanId == 2 ? "basic.png" : x.PlanId == 3 ? "advance.png" : "ultimate.png",
                    Price          = (x.Price + x.UsedUserCreditAmount).ToString(),
                    TotalAccounts  = accounts.ToString(),
                    ApplicationFee = x.ApplicationFee.ToString(),
                    SubTotal       = Math.Round((x.Price)).ToString(),
                    Total          = (Math.Round((x.Price)) + x.ApplicationFee).ToString(),
                    CreditedAmount = x.UsedUserCreditAmount.ToString()
                }).ToList();


                return(invoiceModelList);
            }
            else
            {
                return(null);
            }
        }
Пример #8
0
        public void AddDummyAcountDetails(Guid orgID)
        {
            var countries = new List <string> {
                "AU", "AU", "AU", "AU", "IN", "IN", "IN", "IN", "US", "US", "US", "US"
            };
            var userGroup = new List <string> {
                "AUS_GROUP", "AUS_GROUP", "AUS_GROUP", "AUS_GROUP", "IND_GROUP", "IND_GROUP", "IND_GROUP", "IND_GROUP", "US_GROUP", "US_GROUP", "US_GROUP", "US_GROUP"
            };
            var names = new List <string> {
                "Aadesh", "Aadarsh", "Aadhishankar", "Aadit", "Aagman", "Aagney", "Aahva", "Aakarshan", "Abhay", "Abhi", "Abhijat", "Abhijit", "Abhik", "Abhilash", "Abhinandan", "Abhinav", "Abhinivesh", "Abhiram", "Abhiroop", "Abhirut", "Abhisar", "Abhishek", "Abhyas", "Achal", "Achalraj"
            };
            var cities = new List <string> {
                "Melbourne", "Melbourne", "Brisbane", "Brisbane", "Mumbai", "Mumbai", "Chandigarh", "Chandigarh", "California", "California", "NewYork", "NewYork"
            };
            int count      = 12;
            int timeLineId = 2;//Year

            foreach (var item in countries.Select((Value, Index) => new { Value, Index }))
            {
                AccountDetail account = new AccountDetail();
                account.AccountNumber  = MathCalculations.GenerateRandomNo(6).ToString();
                account.Balance        = MathCalculations.GenerateRandomNo(6);
                account.OrganizationId = orgID;
                //account.DataSourceId = 1;
                account.Name         = names[item.Index];     //it's diff  each time
                account.Country      = item.Value;            //it's same 4 Times
                account.City         = cities[item.Index];    //it's same 2 times
                account.UserGroup    = userGroup[item.Index]; //it's same 4 Times
                account.AccountStats = AddDummyAcountStats(names[item.Index]);

                account.Leverage = MathCalculations.GenerateRandomNo(2);
                if (item.Index > 3)
                {
                    timeLineId = 7;//"1 Week (Current Week)
                }
                if (item.Index > 7)
                {
                    timeLineId = 5;// 1 Month(Current Calender Month)
                }
                //account.InstrumentStats = AddInstrumentStats(timeLineId);
                account.InstrumentStats = AddInstrumentStats(names[item.Index]);

                account.AccountTransactionHistories = AddAccountTransactionHistoryStats();
                _unitOfWork.AccountDetailRepository.Add(account);
                count++;
            }

            //account = new AccountDetail();
            //account.AccountNumber = 2222;
            //account.Balance= 2222;
            //account.OrganizationId = new Guid("d5cc177f-5293-6247-bed7-838438c810a3");
            //account.DataSourceId = "2";
            //account.Name = "Shakeel";
            //account.Leverage = "2:50";
            //account.Country = "AUS";
            //account.City= "Ropar";
            //account.UserGroup = "AUS_1";
            //account.AccountStats = AddDummyAcountStats();
            //account.InstrumentStats = AddInstrumentStats();
            //account.AccountTransactionHistories = AddAccountTransactionHistoryStats();
            //_unitOfWork.AccountDetailRepository.Add(account);

            //account = new AccountDetail();
            //account.AccountNumber = 3333;
            //account.Balance= 3333;
            //account.OrganizationId = new Guid("d5cc177f-5293-6247-bed7-838438c810a3");
            //account.DataSourceId = "1";
            //account.Name = "Mohit";
            //account.Leverage = "5:50";
            //account.Country = "IN";
            //account.City = "Melbourne";
            //account.UserGroup = "IN_1";
            //account.AccountStats = AddDummyAcountStats();
            //account.InstrumentStats = AddInstrumentStats();
            //account.AccountTransactionHistories = AddAccountTransactionHistoryStats();
            //_unitOfWork.AccountDetailRepository.Add(account);

            //account = new AccountDetail();
            //account.AccountNumber = 4444;
            //account.Balance= 4444;
            //account.OrganizationId = new Guid("d5cc177f-5293-6247-bed7-838438c810a3");
            //account.DataSourceId = "4";
            //account.Name = "Aeby";
            //account.Leverage = "4:50";
            //account.Country = "AUS";
            //account.City = "New York";
            //account.UserGroup = "AUS_2";
            //account.AccountStats = AddDummyAcountStats();
            //account.InstrumentStats = AddInstrumentStats();
            //account.AccountTransactionHistories = AddAccountTransactionHistoryStats();
            //_unitOfWork.AccountDetailRepository.Add(account);

            // AddDummyTimeLine();
        }