public async Task <IActionResult> FillBalance(BalanceModel model) { string userid = User.Claims.FirstOrDefault(c => c.Type.Contains("nameidentifier")).Value; var response = await _billingApiClient.GetBalanceByFilterAsync(new BalanceFilter { UserId = userid }); if (response.Data?.FirstOrDefault() == null) { var resp = await _billingApiClient.AddBalanceAsync(new NewBalanceDto { UserId = userid, BalanceValue = model.BalanceValue }); } else { var resp = await _billingApiClient.UpdateBalanceAsync(new UpdateBalanceDto { UserId = userid, BalanceValue = model.BalanceValue + response.Data.FirstOrDefault().BalanceValue }); } return(Redirect("~/")); }
/// <summary> /// Страница маркетплейса /// </summary> /// <returns></returns> public async Task <IActionResult> MarketPlace([FromQuery] long?category, [FromQuery] int page = 1) { ViewData["Category"] = category; ViewData["Page"] = page; var response = await _solutionApiClient.GetAllCategoriesAsync(); ViewBag.Categories = response.Data; var sols = await _solutionApiClient.GetByFilterAsync(new SolutionFilter { Size = 6, CategoryId = category, Page = page }); ViewBag.Solutions = sols.Data; string userid = User.Claims.FirstOrDefault(c => c.Type.Contains("nameidentifier")).Value; var bal = await _billingApiClient.GetBalanceByFilterAsync(new BalanceFilter { UserId = userid }); ViewBag.Balance = bal.Data.FirstOrDefault().BalanceValue; return(View()); }