protected ActionResult <IndexDto <TIndexDto> > Index(int page = 1, int limit = 100) { int offset = (page - 1) * limit; IEnumerable <TModel> projectsCollection = Repository.Index(offset, limit); int count = Repository.Count(); IndexMeta meta = new IndexMeta { Page = page, Limit = limit, Count = count, Resource = Resource }; IEnumerable <TIndexDto> data = Mapper.Map <IEnumerable <TIndexDto> >(projectsCollection); IndexDto <TIndexDto> dto = new IndexDto <TIndexDto>(data, meta); return(Ok(dto)); }
// GET: ProductsController public async Task <ActionResult> Index(int page = 1) { int pageSize = 9; var item = (await _uow.ProductRepository.GetAllAsync()).Where(x => x.Count > 0); var count = item.Count(); var items = item.Skip((page - 1) * pageSize).Take(pageSize).ToList(); PageDto pageDto = new PageDto(count, page, pageSize); IndexDto index = new IndexDto { Page = pageDto, Products = items }; return(View(index)); }
public async Task <IActionResult> GetIndex(string symbol) { using (var client = new HttpClient()) { var url = new Uri($"https://financialmodelingprep.com/api/v3/historical-price-full/index/{symbol}?apikey={_config["FinKey"]}"); var response = await client.GetAsync(url); string json; using (var content = response.Content) { json = await content.ReadAsStringAsync(); } IndexDto stock = JsonConvert.DeserializeObject <IndexDto>(json); var format = stock.Historical; var newFormat = _stockFormatter.GetMonthlyAverage(format); return(Ok(newFormat)); } }
public void EditIndex(IndexDto input) { _userService.CheckUserPermissions(new List <Enum.RoleType> { Enum.RoleType.Administrator }); var userClaim = _userService.UserClaim(); if (input.Id.HasValue) { var assessment = _assessmentIndexRepository.FirstOrDefault(t => t.Id == input.Id); if (assessment != null) { assessment.AssociatProjectType = input.AssociatProjectType; assessment.CompleteStandard = input.CompleteStandard; assessment.Content = input.Content; assessment.IndexType = input.IndexType; assessment.Remark = input.Remark; assessment.StandardScore = input.StandardScore; assessment.UpdateTime = Clock.Now; assessment.UpdateUserId = userClaim.UserId; _assessmentIndexRepository.UpdateAsync(assessment); } } else { _assessmentIndexRepository.InsertAsync(new AssessmentIndexEntity { Id = Guid.NewGuid(), CreateUserId = userClaim.UserId, AssociatProjectType = input.AssociatProjectType, CompleteStandard = input.CompleteStandard, Content = input.Content, IndexType = input.IndexType, Remark = input.Remark, StandardScore = input.StandardScore, Sort = _assessmentIndexRepository.GetAll().OrderByDescending(t => t.Sort).Take(1).Select(t => t.Sort).FirstOrDefault() + 1 }); } }
public async Task <IndexDto> GetIndexInfoAsync(string userId) { var indexDto = new IndexDto { CategoriesLast30DaysExpenses = await this.GetLast30DaysExpensesByCategoryAsync(userId), CategoriesLast30DaysIncomes = await this.GetLast30DaysIncomesByCategoryAsync(userId), ActiveToDoLists = await this.GetActiveListsAsync(userId), Wallets = await this.GetWalletsAsync(userId), InvestmentWallets = await this.GetInvestmentWalletsAsync(userId), AccountRecords = await this.GetLastRecordsAsync(userId, 10), AccountTrades = await this.GetLastTradesAsync(userId, 10), AccountHoldings = await this.GetHoldingsAsync(userId), AccountCategories = await this.GetCategoriesSummaryAsync(userId), TotalAccountExpenses = this.dbContext.Records .Where(r => r.Category.Wallet.ApplicationUserId == userId && r.Type == RecordType.Expense) .Count(), TotalAccountIncomes = this.dbContext.Records .Where(r => r.Category.Wallet.ApplicationUserId == userId && r.Type == RecordType.Income) .Count(), }; return(indexDto); }
private IndexViewModel MapInfoToModel(IndexDto dto) { return(new IndexViewModel() { TotalAccountExpenses = dto.TotalAccountExpenses, TotalAccountIncomes = dto.TotalAccountIncomes, CategoriesLast30DaysExpenses = dto.CategoriesLast30DaysExpenses.Select(ce => new AccountCategoryExpensesLast30DaysViewModel { CategoryId = ce.CategoryId, BadgeColor = Enum.Parse <BadgeColor>(ce.BadgeColor.ToString()), CategoryName = ce.CategoryName, WalletId = ce.WalletId, WalletName = ce.WalletName, CurrencyCode = ce.CurrencyCode, TotalExpenseRecordsLast30Days = ce.TotalExpenseRecordsLast30Days, TotalExpensesLast30Days = ce.TotalExpensesLast30Days, }) .ToList(), CategoriesLast30DaysIncomes = dto.CategoriesLast30DaysIncomes.Select(ci => new AccountCategoryIncomesLast30DaysViewModel { BadgeColor = Enum.Parse <BadgeColor>(ci.BadgeColor.ToString()), CategoryId = ci.CategoryId, CategoryName = ci.CategoryName, WalletId = ci.WalletId, WalletName = ci.WalletName, CurrencyCode = ci.CurrencyCode, TotalIncomeRecordsLast30Days = ci.TotalIncomeRecordsLast30Days, TotalIncomesLast30days = ci.TotalIncomesLast30Days, }) .ToList(), ActiveToDoLists = dto.ActiveToDoLists.Select(l => new IndexListViewModel { Id = l.Id, Name = l.Name, }) .ToList(), Wallets = dto.Wallets.Select(w => new IndexWalletViewModel { Id = w.Id, Name = w.Name, CurrencyCode = w.CurrencyCode, Amount = w.Amount, }) .ToList(), InvestmentWallets = dto.InvestmentWallets.Select(iw => new IndexInvestmentWalletViewModel { Id = iw.Id, CurrencyCode = iw.CurrencyCode, Name = iw.Name, TotalBuyTradesAmount = iw.TotalBuyTradesAmount, TotalSellTradesAmount = iw.TotalSellTradesAmount, }) .ToList(), AccountRecords = dto.AccountRecords.Select(r => new IndexRecordViewModel { Id = r.Id, Amount = r.Amount, CategoryId = r.CategoryId, CategoryName = r.CategoryName, CategoryBadgeColor = Enum.Parse <BadgeColor>(r.CategoryBadgeColor.ToString()), CreatedOn = r.CreatedOn.ToString("dddd, dd MMMM yyyy", CultureInfo.InvariantCulture), CurrencyCode = r.CurrencyCode, Description = r.Description, Type = Enum.Parse <RecordTypeInputModel>(r.Type.ToString()), WalletId = r.WalletId, WalletName = r.WalletName, }) .ToList(), AccountTrades = dto.AccountTrades.Select(t => new IndexTradeViewModel { Id = t.Id, CreatedOn = t.CreatedOn, Price = t.Price, StockQuantity = t.StockQuantity, InvestmentWalletId = t.InvestmentWalletId, InvestmentWalletName = t.InvestmentWalletName, Type = Enum.Parse <TradeType>(t.Type.ToString()), Company = new CompanyViewModel { Name = t.Company.Name, Ticker = t.Company.Ticker, }, Currency = new CurrencyViewModel { Name = t.Currency.Name, CurrencyId = t.Currency.CurrencyId, Code = t.Currency.Code, }, }) .ToList(), AccountHoldings = dto.AccountHoldings.Select(h => new IndexCompanyHoldingsViewModel { BuyTrades = h.BuyTrades, SellTrades = h.SellTrades, StocksHoldings = h.StocksHoldings, Name = h.Name, Ticker = h.Ticker, }) .ToList(), AccountCategories = dto.AccountCategories.Select(c => new IndexCategoriesSummaryViewModel { BadgeColor = Enum.Parse <BadgeColor>(c.BadgeColor.ToString()), CategoryId = c.CategoryId, CategoryName = c.CategoryName, CurrencyCode = c.CurrencyCode, RecordsCount = c.RecordsCount, TotalExpenses = c.TotalExpenses, TotalIncomes = c.TotalIncomes, WalletId = c.WalletId, WalletName = c.WalletName, }) .ToList(), }); }