This commit is contained in:
Николай 2023-04-09 19:15:33 +04:00
parent c8de74e931
commit 7a37e5d985
3 changed files with 44 additions and 31 deletions

View File

@ -25,26 +25,29 @@
</div>
</form>
<script>
$('#dish').on('change', function () {
check();
});
$('#count').on('change', function () {
check();
});
@section Scripts
{
<script>
$('#dish').on('change', function () {
check();
});
$('#count').on('change', function () {
check();
});
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);
}
});
};
}
</script>
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);
}
});
};
}
</script>
}

View File

@ -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<ClientViewModel> GetFilteredList(ClientSearchModel model)

View File

@ -21,6 +21,10 @@ namespace FoodOrdersDatabaseImplement.Implements
public List<OrderViewModel> 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)