Exemple #1
0
        public async Task <ActionResult> Details(string email)
        {
            var account = await AccountFacade.GetAccountAccordingToEmailAsync(email);

            var myAuctions     = (await AuctionFacade.GetAllAuctionsForAccount(account.Id)).ToList();
            var allMyBids      = (await AccountFacade.GetAllBidsAccordingToAccount(account.Id)).ToList();
            var biddedAuctions = new List <AuctionDTO>();

            foreach (var auction in allMyBids)
            {
                biddedAuctions.Add(await AuctionFacade.GetAuctionAsync(auction.AuctionId));
            }
            biddedAuctions = biddedAuctions.Distinct().ToList();

            var biddedAuctionsLastBidAccount = new List <Pair <AuctionDTO, AccountDTO> >();

            foreach (var auction in biddedAuctions)
            {
                biddedAuctionsLastBidAccount.Add(new Pair <AuctionDTO, AccountDTO>(auction, await AccountFacade.GetAccountAccordingToIdAsync(
                                                                                       (await AuctionFacade.GetAllBidsAccordingToAuction(auction.Id)).OrderByDescending(x => x.BidDateTime)
                                                                                       .First().AccountId)));
            }


            AccountDetailModel accountDetailModel = new AccountDetailModel
            {
                AccountDto = account,
                MyAuctions = myAuctions,
                BiddingAuctionsAndLastBid = new List <Pair <AuctionDTO, AccountDTO> >(biddedAuctionsLastBidAccount)
            };

            return(View("AccountDeatilView", accountDetailModel));
        }
Exemple #2
0
        public ActionResult EditAccount(int id, AccountFilterModel filter, FormCollection collection)
        {
            var account = AccountServices.GetAccount(id);

            try
            {
                UpdateModel(account);
                AccountServices.UpdateAccount(account);

                return(RedirectToAction("AccountListing", filter.GenerateAccountListingRoute()));
            }
            catch (Exception ex)
            {
                // Invalid - redisplay with errors
                Logger.Error(ex.ToString());
                ModelState.AddModelError(String.Empty, Constants.ServerError);
                var model = new AccountDetailModel()
                {
                    Action  = "EditAccount",
                    Account = account,
                    Filter  = filter
                };

                ViewBag.AccountTypes = AccountTypeServices.GetAccountTypes(false, account.AccountTypeId);
                ViewBag.StateCodes   = LookupServices.GetStateOptions(account.StateCode);

                return(View("AccountDetail", model));
            }
        }
        public HttpResponseMessage UpdateProfile([FromBody] AccountDetailModel model)
        {
            model.AccountId = UserService.GetCurrentUser().Id;
            adSvc.Update(model);
            ItemResponse <AccountDetailViewModel> resp = new ItemResponse <AccountDetailViewModel>();

            resp.Item = adSvc.SelectByAccountId(model.AccountId);
            return(Request.CreateResponse(HttpStatusCode.OK, resp));
        }
Exemple #4
0
        public void Collect(AccountDetailModel account)
        {
            AccountModel accountModel = _accountBll.GetAccountInfo(account.Aid);

            account.OldAmount    = accountModel.Amount;
            accountModel.Amount  = accountModel.Amount + account.Amount;
            account.NewAmount    = accountModel.Amount;
            account.BusinessType = "C";
            _accountBll.UpdateAccount(accountModel);
            _accountDetailBll.AddAccountDetail(account);
        }
Exemple #5
0
        public void Pay(AccountDetailModel account)
        {
            AccountModel accountModel = _accountBll.GetAccountInfo(account.Aid);

            account.OldAmount    = accountModel.Amount;
            accountModel.Amount  = accountModel.Amount - account.Amount;
            account.NewAmount    = accountModel.Amount;
            account.BusinessType = "P";
            account.Amount       = account.Amount * -1;
            _accountBll.UpdateAccount(accountModel);
            _accountDetailBll.AddAccountDetail(account);
        }
Exemple #6
0
        public ActionResult Edit(int id)
        {
            Account            user  = _accountService.GetById(id);
            AccountDetailModel model = Mapper.Map <AccountDetailModel>(user);

            var customers = _customerService.GetAll();

            model.CustomersList = customers.Select(c => new SelectListItem {
                Value = c.Id.ToString(),
                Text  = c.Name
            });
            return(View(model));
        }
Exemple #7
0
        public ActionResult Add()
        {
            var model = new AccountDetailModel();

            var customers = _customerService.GetAll();

            model.CustomersList = customers.Select(c => new SelectListItem {
                Value = c.Id.ToString(),
                Text  = c.Name
            });

            return(View(model));
        }
Exemple #8
0
        public ActionResult NewAccount(AccountFilterModel filter)
        {
            var model = new AccountDetailModel()
            {
                Action  = "NewAccount",
                Account = new AccountModel(),
                Filter  = filter,
            };

            ViewBag.AccountTypes = AccountTypeServices.GetAccountTypes(false);
            ViewBag.StateCodes   = LookupServices.GetStateOptions("TN");

            return(View("AccountDetail", model));
        }
Exemple #9
0
        public ActionResult EditAccount(int id, AccountFilterModel filter)
        {
            var account = AccountServices.GetAccount(id);

            var model = new AccountDetailModel()
            {
                Action  = "EditAccount",
                Account = account,
                Filter  = filter,
            };

            ViewBag.AccountTypes = AccountTypeServices.GetAccountTypes(false, account.AccountTypeId);
            ViewBag.StateCodes   = LookupServices.GetStateOptions(account.StateCode);

            return(View("AccountDetail", model));
        }
 public IHttpActionResult Put(AccountDetailModel model)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(BadRequest(ModelState));
         }
         _accountDetailService.Update(model);
         return(Ok(model));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Exemple #11
0
 public void Insert(AccountDetailModel model)
 {
     using (SqlConnection conn = new SqlConnection(connStr))
     {
         string cmdStr = "Account_Detail_Insert";
         using (SqlCommand cmd = new SqlCommand(cmdStr, conn))
         {
             cmd.CommandType = System.Data.CommandType.StoredProcedure;
             cmd.Parameters.AddWithValue("@AccountId", model.AccountId);
             cmd.Parameters.AddWithValue("@ProfilePicId", model.ProfilePicId);
             cmd.Parameters.AddWithValue("@Description", model.Description);
             conn.Open();
             cmd.ExecuteNonQuery();
             conn.Close();
         }
     }
 }
Exemple #12
0
        public ActionResult EditUser(AccountDetailModel model)
        {
            try {
                var nowdate    = DateTime.Now;
                var customerId = model.CustomerId.Value;
                if (!model.Id.HasValue)
                {
                    Account user    = new Account();
                    var     newGuid = Guid.NewGuid();
                    user.CreatedDate = nowdate;
                    user.UpdatedDate = nowdate;
                    user.FirstName   = model.FirstName;
                    user.LastName    = model.LastName;
                    user.UserId      = newGuid;
                    user.Email       = model.Email;
                    user.Customer    = _customerService.GetById(customerId);
                    user.IsActive    = Convert.ToBoolean(Request.Form["IsActive"]);

                    var passwordHash = Crypto.HashPassword(model.Password);
                    user.Password = passwordHash;
                    _accountService.Create(user);
                }
                else
                {
                    Account user = _accountService.GetById(model.Id.Value);
                    user.FirstName   = model.FirstName;
                    user.LastName    = model.LastName;
                    user.Email       = model.Email;
                    user.Roles       = UserRoles.User.ToString();
                    user.UpdatedDate = nowdate;
                    user.Customer    = _customerService.GetById(customerId);
                    user.IsActive    = Convert.ToBoolean(Request.Form["IsActive"]);
                    var passwordHash = Crypto.HashPassword(model.Password);
                    user.Password = passwordHash;

                    _accountService.Update(user);
                }
                return(RedirectToAction("Index", "Account"));
            }
            catch (Exception ex) {
                throw ex;
            }
        }
Exemple #13
0
        public void Update(AccountDetailModel model)
        {
            try
            {
                if (_accountDetailRepository.NameExist(model))
                {
                    throw new Exception("Account already exists!");
                }
                var accountDetail = _accountDetailRepository.Find(model.Id);
                if (accountDetail == null)
                {
                    throw new Exception("Account not found");
                }


                _accountDetailRepository.Update(accountDetail);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
Exemple #14
0
 public void Create(AccountDetailModel model)
 {
     try
     {
         if (_accountDetailRepository.NameExist(model))
         {
             throw new Exception("Account already exists!");
         }
         var accountDetail = new AccountDetail()
         {
             // Name = model.Name,
             //Type = model.Type,
             // Number = model.Number,
             //BankName = model.BankName
         };
         _accountDetailRepository.Insert(accountDetail);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
Exemple #15
0
 public bool NameExist(AccountDetailModel model)
 {
     //return GetAll().Any(c => c.Id != model.Id && model.Name.Equals(c.Name,StringComparison.OrdinalIgnoreCase));
     return(false);
 }
        public async Task <GetAccountResult> Handle(GetAccountQuery query, CancellationToken cancellationToken)
        {
            try
            {
                AccountDetailModel acctDetails = new AccountDetailModel();
                acctDetails = await _accountService.GetAccountDetail(query.AccountNumber, query.AccountPIN);

                if (acctDetails != null)
                {
                    //Validate PIN
                    if (!BC.Verify(query.AccountPIN, acctDetails.AccountPIN))
                    {
                        return(new GetAccountResult
                        {
                            StatusCode = Convert.ToInt32(HttpStatusCode.OK),
                            Message = Convert.ToString(HttpStatusCode.OK),
                            MessageDetails = ManageAccountStatus.InvalidAccountPIN,
                            AcctId = acctDetails.AcctId,
                            FirstName = acctDetails.FirstName,
                            MiddleName = acctDetails.MiddleName,
                            LastName = acctDetails.LastName,
                            AccountNumber = acctDetails.AccountNumber
                        });
                    }
                    else
                    {
                        return(new GetAccountResult
                        {
                            StatusCode = Convert.ToInt32(HttpStatusCode.OK),
                            Message = Convert.ToString(HttpStatusCode.OK),
                            MessageDetails = ManageAccountStatus.AccountDetailRetrieveSuccessful,
                            AcctId = acctDetails.AcctId,
                            FirstName = acctDetails.FirstName,
                            MiddleName = acctDetails.MiddleName,
                            LastName = acctDetails.LastName,
                            AccountNumber = acctDetails.AccountNumber,
                            AccountPIN = acctDetails.AccountPIN,
                            AccountType = acctDetails.AccountType,
                            AccountStatus = acctDetails.AccountStatus,
                            InitialAmountDeposit = acctDetails.InitialAmountDeposit,
                            DateCreated = acctDetails.DateCreated,
                            DateUpdated = acctDetails.DateUpdated
                        });
                    }
                }
                else
                {
                    return(new GetAccountResult
                    {
                        StatusCode = Convert.ToInt32(HttpStatusCode.OK),
                        Message = Convert.ToString(HttpStatusCode.OK),
                        MessageDetails = ManageAccountStatus.InvalidAccountNumber
                    });
                }
            }
            catch (Exception ex)
            {
                _logger.LogError("Error retrieving account details : {ExceptionMessage}", ex.ToString());

                return(new GetAccountResult
                {
                    StatusCode = Convert.ToInt32(HttpStatusCode.InternalServerError),
                    Message = Convert.ToString(HttpStatusCode.InternalServerError),
                    MessageDetails = ManageAccountStatus.AccountDetailRetrieveFailed
                });
            }
        }
Exemple #17
0
 public bool DeleteAccount(AccountDetailModel model)
 {
     throw new NotImplementedException();
 }
        public AnalyticsResponse GetNavMapData(Guid orgId, int timelineId, string[] userGroups, string userGroup = "", string country = "", string city = "")
        {
            var response = new AnalyticsResponse();
            // int timeLineID = 7;

            List <AccountDetail> accountDetail = new List <AccountDetail>();

            if (string.IsNullOrEmpty(country))
            {
                accountDetail = _unitOfWork.AccountDetailRepository.GetAll().Where(m => m.OrganizationId == orgId && userGroups.Contains(m.UserGroup)).ToList();
            }
            else if (!string.IsNullOrEmpty(country) && string.IsNullOrEmpty(city) && string.IsNullOrEmpty(userGroup))
            {
                accountDetail = _unitOfWork.AccountDetailRepository.GetAll().Where(m => m.OrganizationId == orgId && userGroups.Contains(m.UserGroup) && m.Country == country).ToList();
            }
            else if (!string.IsNullOrEmpty(country) && !string.IsNullOrEmpty(city) && string.IsNullOrEmpty(userGroup))
            {
                accountDetail = _unitOfWork.AccountDetailRepository.GetAll().Where(m => m.OrganizationId == orgId && userGroups.Contains(m.UserGroup) && m.Country == country && m.City == city).ToList();
            }
            else if (!string.IsNullOrEmpty(userGroup) && string.IsNullOrEmpty(country) && string.IsNullOrEmpty(city))
            {
                accountDetail = _unitOfWork.AccountDetailRepository.GetAll().Where(m => m.OrganizationId == orgId && userGroups.Contains(m.UserGroup) && m.UserGroup == userGroup).ToList();
            }
            else if (!string.IsNullOrEmpty(userGroup) && !string.IsNullOrEmpty(country) && string.IsNullOrEmpty(city))
            {
                accountDetail = _unitOfWork.AccountDetailRepository.GetAll().Where(m => m.OrganizationId == orgId && userGroups.Contains(m.UserGroup) && m.UserGroup == userGroup && m.Country == country).ToList();
            }
            else if (!string.IsNullOrEmpty(userGroup) && !string.IsNullOrEmpty(country) && !string.IsNullOrEmpty(city))
            {
                accountDetail = _unitOfWork.AccountDetailRepository.GetAll().Where(m => m.OrganizationId == orgId && userGroups.Contains(m.UserGroup) && m.UserGroup == userGroup && m.Country == country && m.City == city).Take(5).ToList();
            }
            var timeLineIds = accountDetail.SelectMany(x => x.AccountStats).Select(x => x.TimeLineId).Distinct().ToList();

            accountDetail.ForEach(x => x.AccountStats = x.AccountStats.Where(t => t.TimeLineId == timelineId).ToList());

            var accountsData = new AccountDetailModel().ToComparisonData(accountDetail);

            response.Data = accountsData;
            //response.Cities = accountDetail.Select(x => x.City).Distinct();
            // response.Countries = accountDetail.Select(x => x.Country).Distinct();
            // response.Accounts = accountDetail.Select(x => x.Name).Distinct();
            List <AccountDetailModel> aD = new List <AccountDetailModel>();

            foreach (string item in accountsData.Select(x => x.City).Distinct())
            {
                aD.Add(new AccountDetailModel()
                {
                    City = item, Nav = accountsData.Where(z => z.City == item).SelectMany(n => n.AccountStats).Sum(x => x.NAV)
                });
            }

            response.Cities = aD.OrderByDescending(n => n.Nav).Take(5).Select(x => x.City).Distinct();

            aD = new List <AccountDetailModel>();
            foreach (string item in accountDetail.Select(x => x.Country).Distinct())
            {
                aD.Add(new AccountDetailModel()
                {
                    Country = item, Nav = accountsData.Where(z => z.Country == item).SelectMany(n => n.AccountStats).Sum(x => x.NAV)
                });
            }

            response.Countries = aD.OrderByDescending(n => n.Nav).Take(5).Select(x => x.Country).Distinct();

            aD = new List <AccountDetailModel>();
            foreach (string item in accountsData.Select(x => x.Name).Distinct())
            {
                aD.Add(new AccountDetailModel()
                {
                    Name = item, Nav = accountsData.Where(z => z.Name == item).SelectMany(n => n.AccountStats).Sum(x => x.NAV)
                });
            }

            response.Accounts = accountDetail.OrderByDescending(n => n.Name).Take(5).Select(x => x.Name).Distinct();
            var timeLines = new List <EnumHelper>();

            foreach (var tline in Timelines.MasterTimelines)
            {
                var timeline = new EnumHelper
                {
                    stringValue = tline.Encrypt(),
                    DisplayName = ((TimeLineEnum)Enum.ToObject(typeof(TimeLineEnum), tline)).GetEnumDisplayName()
                };
                timeLines.Add(timeline);
            }
            //foreach (var timeLineId in timeLineIds.OrderBy(x => x).ToList())
            //{
            //    var timeline = new EnumHelper
            //    {
            //        stringValue = timeLineId.Encrypt(),
            //        DisplayName = ((TimeLineEnum)Enum.ToObject(typeof(TimeLineEnum), Convert.ToInt32(timeLineId))).GetEnumDisplayName()
            //    };
            //    timeLines.Add(timeline);
            //}
            response.Timelines = timeLines;
            response.WidgetId  = Convert.ToInt32(EmbedWidgetEnum.Nav).Encrypt();
            return(response);

            //var response = new AnalyticsResponse();
            //// int timeLineID = 7;

            //List<AccountDetail> accountDetail = new List<AccountDetail>();
            //if (string.IsNullOrEmpty(country))
            //{
            //    accountDetail = _unitOfWork.AccountDetailRepository.GetAll().Where(m => m.OrganizationId == orgId).ToList();
            //}
            //else if (!string.IsNullOrEmpty(country) && string.IsNullOrEmpty(city) && string.IsNullOrEmpty(userGroup))
            //{
            //    accountDetail = _unitOfWork.AccountDetailRepository.GetAll().Where(m => m.OrganizationId == orgId && m.Country == country).ToList();
            //}
            //else if (!string.IsNullOrEmpty(country) && !string.IsNullOrEmpty(city) && string.IsNullOrEmpty(userGroup))
            //{
            //    accountDetail = _unitOfWork.AccountDetailRepository.GetAll().Where(m => m.OrganizationId == orgId && m.Country == country && m.City == city).ToList();
            //}
            //else if (!string.IsNullOrEmpty(userGroup) && string.IsNullOrEmpty(country) && string.IsNullOrEmpty(city))
            //{
            //    accountDetail = _unitOfWork.AccountDetailRepository.GetAll().Where(m => m.OrganizationId == orgId && m.UserGroup == userGroup).ToList();
            //}
            //else if (!string.IsNullOrEmpty(userGroup) && !string.IsNullOrEmpty(country) && string.IsNullOrEmpty(city))
            //{
            //    accountDetail = _unitOfWork.AccountDetailRepository.GetAll().Where(m => m.OrganizationId == orgId && m.UserGroup == userGroup && m.Country == country).ToList();
            //}
            //else if (!string.IsNullOrEmpty(userGroup) && !string.IsNullOrEmpty(country) && !string.IsNullOrEmpty(city))
            //{
            //    accountDetail = _unitOfWork.AccountDetailRepository.GetAll().Where(m => m.OrganizationId == orgId && m.UserGroup == userGroup && m.Country == country && m.City == city).Take(5).ToList();
            //}
            //var timeLineIds = accountDetail.SelectMany(x => x.AccountStats).Select(x => x.TimeLineId).Distinct().ToList();
            //accountDetail.ForEach(x => x.AccountStats = x.AccountStats.Where(t => t.TimeLineId == timelineId).ToList());

            //var accountsData = new AccountDetailModel().ToComparisonData(accountDetail);
            //response.Data = accountsData;
            ////response.Cities = accountDetail.Select(x => x.City).Distinct();
            //// response.Countries = accountDetail.Select(x => x.Country).Distinct();
            //// response.Accounts = accountDetail.Select(x => x.Name).Distinct();
            //List<AccountDetailModel> aD = new List<AccountDetailModel>();
            //foreach (string item in accountsData.Select(x => x.City).Distinct())
            //{
            //    aD.Add(new AccountDetailModel() { City = item, Nav = accountsData.Where(z => z.City == item).SelectMany(n => n.AccountStats).Sum(x => x.NAV) });
            //}

            //response.Cities = aD.OrderByDescending(n => n.Nav).Select(x => x.City).Distinct();

            //aD = new List<AccountDetailModel>();
            //foreach (string item in accountDetail.Select(x => x.Country).Distinct())
            //{
            //    aD.Add(new AccountDetailModel() { Country = item, Nav = accountsData.Where(z => z.Country == item).SelectMany(n => n.AccountStats).Sum(x => x.NAV) });
            //}

            //response.Countries = aD.OrderByDescending(n => n.Nav).Select(x => x.Country).Distinct();

            //aD = new List<AccountDetailModel>();
            //foreach (string item in accountsData.Select(x => x.Name).Distinct())
            //{
            //    aD.Add(new AccountDetailModel() { Name = item, Nav = accountsData.Where(z => z.Name == item).SelectMany(n => n.AccountStats).Sum(x => x.NAV) });
            //}

            //response.Accounts = accountDetail.OrderByDescending(n => n.Name).Select(x => x.Name).Distinct();
            //var timeLines = new List<EnumHelper>();
            //foreach (var timeLineId in timeLineIds.OrderBy(x => x).ToList())
            //{
            //    var timeline = new EnumHelper
            //    {
            //        stringValue = timeLineId.Encrypt(),
            //        DisplayName = ((TimeLineEnum)Enum.ToObject(typeof(TimeLineEnum), Convert.ToInt32(timeLineId))).GetEnumDisplayName()
            //    };
            //    timeLines.Add(timeline);
            //}
            //response.Timelines = timeLines;
            //return response;
        }
        public AnalyticsResponse GetInstrumentStats(Guid orgId, int timelineId, string[] userGroups, string instrument = "", string country = "", string city = "")
        {
            var response = new AnalyticsResponse();
            List <AccountDetail> accountDetail = new List <AccountDetail>();
            var topInstruments = _unitOfWork.AccountDetailRepository.GetAll().Where(m => m.OrganizationId == orgId && userGroups.Contains(m.UserGroup)).SelectMany(x => x.InstrumentStats).GroupBy(x => x.InstrumentName)
                                 .Select(g => new
            {
                Key   = g.Key,
                Value = g.Sum(s => s.Volume),
            }).OrderByDescending(x => x.Value).Select(x => x.Key).Take(5).ToList();

            if (string.IsNullOrEmpty(country) && string.IsNullOrEmpty(city))
            {
                //var aaccountDetail = _unitOfWork.AccountDetailRepository.GetAll().Where(m => m.OrganizationId == orgId && m.InstrumentStats.Any(x => x.TimeLineId == timelineId))
                //                   .SelectMany(x => x.InstrumentStats).OrderByDescending(x => x.Volume).ToList();
                accountDetail = _unitOfWork.AccountDetailRepository.GetAll().Where(m => m.OrganizationId == orgId && userGroups.Contains(m.UserGroup)).ToList();

                accountDetail.ForEach(x => x.InstrumentStats = x.InstrumentStats.Where(t => t.TimeLineId == timelineId && topInstruments.Contains(t.InstrumentName)).ToList());
            }
            else if (!string.IsNullOrEmpty(country) && string.IsNullOrEmpty(city))
            {
                accountDetail = _unitOfWork.AccountDetailRepository.GetAll().Where(m => m.OrganizationId == orgId && userGroups.Contains(m.UserGroup) && m.Country == country).ToList();
                accountDetail.ForEach(x => x.InstrumentStats = x.InstrumentStats.Where(t => t.TimeLineId == timelineId && t.InstrumentName == instrument && topInstruments.Contains(t.InstrumentName)).ToList());
            }
            if (!string.IsNullOrEmpty(country) && !string.IsNullOrEmpty(city))
            {
                accountDetail = _unitOfWork.AccountDetailRepository.GetAll().Where(m => m.OrganizationId == orgId && userGroups.Contains(m.UserGroup) && m.Country == country && m.City == city).ToList();
                accountDetail.ForEach(x => x.InstrumentStats = x.InstrumentStats.Where(t => t.TimeLineId == timelineId && t.InstrumentName == instrument && topInstruments.Contains(t.InstrumentName)).ToList());
            }


            var accountsData = new AccountDetailModel().ToAccountDetailWithInstrumentStatsModel(accountDetail);

            response.Data = accountsData.OrderByDescending(x => x.InstrumentStatsModel.Sum(y => y.Volume)).ToList();
            //response.Cities = accountDetail.Select(x => x.City).Distinct().ToList();

            //  response.Accounts = accountsData.Select(x => x.Name).Distinct();
            //response.Instruments = accountsData.SelectMany(x => x.InstrumentStatsModel).Select(x => x.InstrumentName).Distinct();
            response.Instruments = topInstruments;

            List <AccountDetailModel> aD = new List <AccountDetailModel>();

            foreach (string item in accountsData.Select(x => x.City).Distinct())
            {
                aD.Add(new AccountDetailModel()
                {
                    City = item, Nav = accountsData.Where(z => z.City == item).SelectMany(n => n.InstrumentStatsModel).Sum(x => x.Volume)
                });
            }

            response.Cities = aD.OrderByDescending(n => n.Nav).Take(5).Select(x => x.City).Distinct();

            aD = new List <AccountDetailModel>();
            foreach (string item in accountsData.Select(x => x.Name).Distinct())
            {
                aD.Add(new AccountDetailModel()
                {
                    Name = item, Nav = accountsData.Where(z => z.Name == item).SelectMany(n => n.InstrumentStatsModel).Sum(x => x.Volume)
                });
            }

            response.Accounts = aD.OrderByDescending(n => n.Nav).Take(5).Select(x => x.Name).Distinct();
            aD = new List <AccountDetailModel>();
            foreach (string item in accountDetail.Select(x => x.Country).Distinct())
            {
                aD.Add(new AccountDetailModel()
                {
                    Country = item, Nav = accountsData.Where(z => z.Country == item).SelectMany(n => n.InstrumentStatsModel).Sum(x => x.Volume)
                });
            }

            response.Countries = aD.OrderByDescending(n => n.Nav).Take(5).Select(x => x.Country).Distinct();
            var timeLineIds = accountDetail.SelectMany(x => x.AccountStats).Select(x => x.TimeLineId).Distinct().ToList();
            var timeLines   = new List <EnumHelper>();

            foreach (var tline in Timelines.MasterTimelines)
            {
                var timeline = new EnumHelper
                {
                    stringValue = tline.Encrypt(),
                    DisplayName = ((TimeLineEnum)Enum.ToObject(typeof(TimeLineEnum), tline)).GetEnumDisplayName()
                };
                timeLines.Add(timeline);
            }
            //foreach (var timeLineId in timeLineIds.OrderBy(x => x).ToList())
            //{
            //    var timeline = new EnumHelper
            //    {
            //        stringValue = timeLineId.Encrypt(),
            //        DisplayName = ((TimeLineEnum)Enum.ToObject(typeof(TimeLineEnum), Convert.ToInt32(timeLineId))).GetEnumDisplayName()
            //    };
            //    timeLines.Add(timeline);
            //}
            response.Timelines = timeLines;
            response.WidgetId  = Convert.ToInt32(EmbedWidgetEnum.InstrumentLocation).Encrypt();
            return(response);
        }