Пример #1
0
        public async Task <List <TaskApproveModel> > GetTasksForAdmin(int pageSize, int pageIndex)
        {
            var listTasksModel = new List <TaskApproveModel>();
            var taskFunds      = await _fund.GetFundByStatus(EditStatus.Updating);

            var taskPortfolios = await _portfolio.GetPortfolioByStatus(EditStatus.Updating);

            var infoFund = taskFunds.Find(x => x.LastUpdatedBy != null);

            if (taskFunds != null && taskFunds.Count > 0)
            {
                var task = new TaskApproveModel();
                task.IdTask          = infoFund != null ? infoFund.Id: 0;
                task.NameTask        = Model.Resources.Common.ApprovedNAVName;
                task.TaskType        = TaskApproveAdmin.Nav;
                task.DateLastUpdated = infoFund != null ? infoFund.DateLastUpdated : DateTime.MinValue;
                task.LastUpdatedBy   = infoFund?.LastUpdatedBy;
                listTasksModel.Add(task);
            }
            if (taskPortfolios != null && taskPortfolios.Count > 0)
            {
                foreach (var portfolio in taskPortfolios)
                {
                    var portfolioFund = _portfolio.GetPortfolioFundByPortfolioId(portfolio.Id, EditStatus.Updating).Result;
                    var infoPortfolio = portfolioFund.Find(x => x.LastUpdatedBy != null);
                    if (portfolioFund.Count > 0)
                    {
                        var task = new TaskApproveModel();
                        task.IdTask          = portfolio.Id;
                        task.NameTask        = portfolio.Title;
                        task.TaskType        = TaskApproveAdmin.Portfolio;
                        task.DateLastUpdated = infoPortfolio != null ? infoPortfolio.DateLastUpdated : DateTime.MinValue;
                        task.LastUpdatedBy   = infoPortfolio?.LastUpdatedBy;
                        listTasksModel.Add(task);
                    }
                }
            }
            listTasksModel = listTasksModel.OrderBy(x => x.DateLastUpdated).ToList();
            return(listTasksModel);
        }