ПИбд-22 Боровков М В 5 лабораторная работа #6

Closed
bekodeg wants to merge 44 commits from labWork5 into labWork4
3 changed files with 19 additions and 19 deletions
Showing only changes of commit ff0dd6f3eb - Show all commits

View File

@ -115,7 +115,7 @@ namespace SushiBarClientApp.Controllers
return View();
}
[HttpPost]
public void Create(int iceCream, int count)
public void Create(int sushi, int count)
{
if (APIClient.Client == null)
{
@ -129,19 +129,19 @@ namespace SushiBarClientApp.Controllers
OrderBindingModel
{
ClientId = APIClient.Client.Id,
SushiId = iceCream,
SushiId = sushi,
Count = count,
Sum = Calc(count, iceCream)
Sum = Calc(count, sushi)
});
Response.Redirect("Index");
}
[HttpPost]
public double Calc(int count, int iceCream)
public double Calc(int count, int sushi)
{
var _iceCream =
APIClient.GetRequest<SushiViewModel>($"api/main/getsushi?sushiid={iceCream}"
var _sushi =
APIClient.GetRequest<SushiViewModel>($"api/main/getsushi?sushiid={sushi}"
);
return Math.Round(count * (_iceCream?.Price ?? 1), 2);
return Math.Round(count * (_sushi?.Price ?? 1), 2);
}
}
}

View File

@ -24,7 +24,7 @@ namespace SushiBarDatabaseImplement.Implements
(!model.Id.HasValue || c.Id == model.Id) &&
(string.IsNullOrEmpty(model.ClientFIO) || c.ClientFIO.Contains(model.ClientFIO)) &&
(string.IsNullOrEmpty(model.Email) || c.Email.Contains(model.Email)) &&
(string.IsNullOrEmpty(model.Password) || c.Password.Contains(model.Password)))
(string.IsNullOrEmpty(model.Password) || c.Password.Equals(model.Password)))
.Select(c => c.GetViewModel)
.ToList();
}
@ -35,8 +35,8 @@ namespace SushiBarDatabaseImplement.Implements
.FirstOrDefault(c =>
(!model.Id.HasValue || c.Id == model.Id) &&
(string.IsNullOrEmpty(model.ClientFIO) || c.ClientFIO.Contains(model.ClientFIO)) &&
(string.IsNullOrEmpty(model.Email) || c.Email.Contains(model.Email)) &&
(string.IsNullOrEmpty(model.Password) || c.Password.Contains(model.Password)))?
(string.IsNullOrEmpty(model.Email) || c.Email.Equals(model.Email)) &&
(string.IsNullOrEmpty(model.Password) || c.Password.Equals(model.Password)))?
.GetViewModel;
}
public ClientViewModel? Insert(ClientBindingModel model)

View File

@ -12,39 +12,39 @@ namespace SushiBarRestApi.Controllers
{
private readonly ILogger _logger;
private readonly IOrderLogic _order;
private readonly ISushiLogic _iceCream;
public MainController(ILogger<MainController> logger, IOrderLogic order, ISushiLogic iceCream)
private readonly ISushiLogic _sushi;
public MainController(ILogger<MainController> logger, IOrderLogic order, ISushiLogic sushi)
{
_logger = logger;
_order = order;
_iceCream = iceCream;
_sushi = sushi;
}
[HttpGet]
public List<SushiViewModel>? GetSushiList()
{
try
{
return _iceCream.ReadList(null);
return _sushi.ReadList(null);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения списка мороженного");
_logger.LogError(ex, "Ошибка получения списка суши");
throw;
}
}
[HttpGet]
public SushiViewModel? GetSushi(int iceCreamId)
public SushiViewModel? GetSushi(int sushiId)
{
try
{
return _iceCream.ReadElement(new SushiSearchModel
return _sushi.ReadElement(new SushiSearchModel
{
Id = iceCreamId
Id = sushiId
});
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения продукта по id={Id}", iceCreamId);
_logger.LogError(ex, "Ошибка получения продукта по id={Id}", sushiId);
throw;
}
}