пожалуй ошибся не я

This commit is contained in:
antoc0der 2024-05-23 21:12:04 +04:00
parent f1f97916a8
commit 47ab8f7e72
4 changed files with 11 additions and 10 deletions

View File

@ -93,12 +93,12 @@ namespace VeterinaryBusinessLogic.BusinessLogic
{
throw new ArgumentNullException("Нет названия визита", nameof(model.VisitName));
}
if (model.DateVisit != null)
if (model.DateVisit == null)
{
throw new ArgumentNullException("Нет времени визита",
nameof(model.DateVisit));
}
if (model.DateVisit >= DateTime.Now)
if (model.DateVisit <= DateTime.Now)
{
throw new ArgumentNullException("Дата посещения не должна быть в прошлом", nameof(model.DateVisit));
}

View File

@ -19,13 +19,10 @@ namespace VeterinaryDatabaseImplement.Implements
}
public List<PetViewModel> GetFilteredList(PetSearchModel model)
{
if (string.IsNullOrEmpty(model.PetName))
{
return new();
}
using var context = new VeterinaryDatabase();
return context.Pets.Where(x => x.OwnerId == model.OwnerId)
.Where(x => x.PetName.Contains(model.PetName))
.Where(x => String.IsNullOrEmpty(model.PetName) || x.PetName.Contains(model.PetName))
.Select(x => x.GetViewModel)
.ToList();
}
@ -103,8 +100,7 @@ namespace VeterinaryDatabaseImplement.Implements
public PetViewModel? Update(PetBindingModel model)
{
using var context = new VeterinaryDatabase();
var component = context.Pets.FirstOrDefault(x => x.Id ==
model.Id);
var component = context.Pets.FirstOrDefault(x => x.Id ==model.Id);
if (component == null)
{
return null;

View File

@ -15,7 +15,7 @@
<div class="row">
<div class="col-4">Дата:</div>
<div class="col-8">
<input type="datetime" id="datetime" name="date" />
<input type="datetime-local" id="datetime" name="datetime" />
</div>
</div>
<div class="row">

View File

@ -29,6 +29,11 @@
<div class="col-8"><input type="text" id="gender" name="gender" class="form-control" /></div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Сохранить" class="btn btn-primary" /></div>
</div>
</form>
@section Scripts