View Model for Creditings

This commit is contained in:
shadowik 2023-05-17 16:46:18 +04:00
parent f5a129511b
commit de87a95cf2
4 changed files with 40 additions and 2 deletions

View File

@ -210,7 +210,12 @@ namespace BankYouBankruptClientApp.Controllers
return Redirect("~/Home/Enter");
}
ViewBag.Cards = APIClient.GetRequest<List<CardViewModel>>($"api/Card/GetUsersCardsList?id={APIClient.Client.Id}");
ViewBag.Cards = APIClient.GetRequest<List<CardViewModel>>($"api/Card/GetAllCards").Select(x => new ClientCardViewModel
{
Id = x.Id,
FullName = x.ClientSurname + " " +x.Number.ToString()
}).ToList();
return View();
}

View File

@ -9,7 +9,7 @@
<div class="row">
<div class="col-4">Номер счета:</div>
<div class="col-8">
<select id="cardId" name="cardId" class="form-control" asp-items="@(new SelectList( @ViewBag.Cards, "Id", "Number"))"></select>
<select id="cardId" name="cardId" class="form-control" asp-items="@(new SelectList( @ViewBag.Cards, "Id", "FullName"))"></select>
</div>
</div>
<div class="row">

View File

@ -0,0 +1,17 @@
using BankYouBankruptDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankYouBankruptContracts.ViewModels
{
public class ClientCardViewModel
{
public int Id { get; set; }
public string FullName { get; set; } = string.Empty;
}
}

View File

@ -31,6 +31,22 @@ namespace BankYouBankruptRestApi.Controllers
_accountLogic = accountLogic;
}
[HttpGet]
public List<CardViewModel>? GetAllCards()
{
try
{
return _cardLogic.ReadList(null);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения карт");
throw;
}
}
[HttpGet]
public List<CardViewModel>? GetUsersCardsList(int id)
{