diff --git a/FoodOrders/FoddOrdersClientApp/Views/Home/Create.cshtml b/FoodOrders/FoddOrdersClientApp/Views/Home/Create.cshtml
index 0fd432a..2dd8cbc 100644
--- a/FoodOrders/FoddOrdersClientApp/Views/Home/Create.cshtml
+++ b/FoodOrders/FoddOrdersClientApp/Views/Home/Create.cshtml
@@ -25,26 +25,29 @@
-
\ No newline at end of file
+ function check() {
+ var count = $('#count').val();
+ var dish = $('#dish').val();
+ if (count && dish) {
+ $.ajax({
+ method: "POST",
+ url: "/Home/Calc",
+ data: { count: count, dish: dish },
+ success: function (result) {
+ $("#sum").val(result);
+ }
+ });
+ };
+ }
+
+}
\ No newline at end of file
diff --git a/FoodOrders/FoodOrdersDatabaseImplement/Implements/ClientStorage.cs b/FoodOrders/FoodOrdersDatabaseImplement/Implements/ClientStorage.cs
index 41cb366..be980c9 100644
--- a/FoodOrders/FoodOrdersDatabaseImplement/Implements/ClientStorage.cs
+++ b/FoodOrders/FoodOrdersDatabaseImplement/Implements/ClientStorage.cs
@@ -23,15 +23,21 @@ namespace FoodOrdersDatabaseImplement.Implements
public ClientViewModel? GetElement(ClientSearchModel model)
{
- if (string.IsNullOrEmpty(model.Email) && !model.Id.HasValue)
- {
- return null;
- }
using var context = new FoodOrdersDatabase();
- return context.Clients
- .FirstOrDefault(x => (!string.IsNullOrEmpty(model.Email) && x.Email == model.Email) ||
- (model.Id.HasValue && x.Id == model.Id))
- ?.GetViewModel;
+ if (model.Id.HasValue)
+ return context.Clients
+ .FirstOrDefault(x => x.Id == model.Id)?
+ .GetViewModel;
+ if (!string.IsNullOrEmpty(model.Email) && !string.IsNullOrEmpty(model.Password))
+ return context.Clients
+ .FirstOrDefault(x => x.Email
+ .Equals(model.Email) && x.Password
+ .Equals(model.Password))?
+ .GetViewModel;
+ if (!string.IsNullOrEmpty(model.Email))
+ return context.Clients
+ .FirstOrDefault(x => x.Email.Equals(model.Email))?.GetViewModel;
+ return null;
}
public List GetFilteredList(ClientSearchModel model)
diff --git a/FoodOrders/FoodOrdersDatabaseImplement/Implements/OrderStorage.cs b/FoodOrders/FoodOrdersDatabaseImplement/Implements/OrderStorage.cs
index 1a56681..fdfae89 100644
--- a/FoodOrders/FoodOrdersDatabaseImplement/Implements/OrderStorage.cs
+++ b/FoodOrders/FoodOrdersDatabaseImplement/Implements/OrderStorage.cs
@@ -21,6 +21,10 @@ namespace FoodOrdersDatabaseImplement.Implements
public List GetFilteredList(OrderSearchModel model)
{
+ if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.ClientId.HasValue)
+ {
+ return new();
+ }
using var context = new FoodOrdersDatabase();
if (model.ClientId.HasValue)
{
@@ -31,7 +35,7 @@ namespace FoodOrdersDatabaseImplement.Implements
.Select(x => x.GetViewModel)
.ToList();
}
- if (!model.Id.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue)
+ else if (model.DateFrom.HasValue && model.DateTo.HasValue)
{
return context.Orders
.Include(x => x.Dish)