Многое начало, для многих
This commit is contained in:
parent
7c0c56acb7
commit
b1a3c8923c
@ -71,7 +71,7 @@ namespace VeterinaryClinicBusinessLogics.BusinessLogics
|
||||
|
||||
public List<AnimalViewModel>? ReadList(AnimalSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Animal.Id: {Id}. UserId: {DoctorId}", model?.Id, model?.UserId);
|
||||
_logger.LogInformation("ReadList. Animal.Id: {Id}. UserId: {UserId}", model?.Id, model?.UserId);
|
||||
|
||||
var list = model == null ? _animalStorage.GetFullList() : _animalStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
|
@ -53,18 +53,21 @@ namespace VeterinaryClinicDatabaseImplement.Implements
|
||||
{
|
||||
using var context = new VeterinaryClinicDatabase();
|
||||
|
||||
if (!string.IsNullOrEmpty(model.Breed))
|
||||
{
|
||||
return context.Animals
|
||||
var filtered = context.Animals
|
||||
.Include(x => x.User)
|
||||
.Include(x => x.Medications)
|
||||
.ThenInclude(x => x.Medication)
|
||||
.Where(x => x.Breed.Contains(model.Breed))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
|
||||
if (model.UserId.HasValue)
|
||||
{
|
||||
filtered = filtered
|
||||
.Where(x => x.UserId.Equals(model.UserId))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
return new();
|
||||
return filtered ?? new();
|
||||
}
|
||||
|
||||
public List<AnimalViewModel> GetFullList()
|
||||
@ -74,7 +77,6 @@ namespace VeterinaryClinicDatabaseImplement.Implements
|
||||
.Include(x => x.User)
|
||||
.Include(x => x.Medications)
|
||||
.ThenInclude(x => x.Medication)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
@ -47,10 +47,10 @@ namespace VeterinaryClinicDatabaseImplement.Implements
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(model.Phone))
|
||||
if (!string.IsNullOrEmpty(model.Email))
|
||||
{
|
||||
return context.Users
|
||||
.FirstOrDefault(x => x.Phone.Equals(model.Phone))
|
||||
.FirstOrDefault(x => x.Email.Equals(model.Email))
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
|
@ -58,17 +58,20 @@ namespace VeterinaryClinicDatabaseImplement.Implements
|
||||
{
|
||||
using var database = new VeterinaryClinicDatabase();
|
||||
|
||||
if (!string.IsNullOrEmpty(model.Name))
|
||||
{
|
||||
return database.Vaccinations
|
||||
var filtered = database.Vaccinations
|
||||
.Include(x => x.User)
|
||||
.Include(x => x.Animal)
|
||||
.Where(x => x.Name.Contains(model.Name))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
|
||||
if (model.UserId.HasValue)
|
||||
{
|
||||
filtered = filtered
|
||||
.Where(x => x.UserId.Equals(model.UserId))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
return new();
|
||||
return filtered ?? new();
|
||||
}
|
||||
|
||||
public List<VaccinationViewModel> GetFullList()
|
||||
|
@ -33,7 +33,7 @@ namespace VeterinaryClinicDatabaseImplement.Models
|
||||
[ForeignKey("AnimalId")]
|
||||
public virtual List<AnimalMedication> Medications { get; set; } = new();
|
||||
|
||||
private Dictionary<int, IMedicationModel>? _animalMedications { get; set; } = new();
|
||||
private Dictionary<int, IMedicationModel>? _animalMedications = null;
|
||||
|
||||
[NotMapped]
|
||||
public Dictionary<int, IMedicationModel> AnimalMedications { get
|
||||
|
@ -54,6 +54,7 @@ namespace VeterinaryClinicDatabaseImplement.Models
|
||||
|
||||
Name = model.Name;
|
||||
Cost = model.Cost;
|
||||
MedicationId = model.MedicationId;
|
||||
}
|
||||
|
||||
public ServiceViewModel GetViewModel => new()
|
||||
|
@ -47,6 +47,7 @@ namespace VeterinaryClinicDatabaseImplement.Models
|
||||
Id = model.Id,
|
||||
Name = model.Name,
|
||||
DateInjection = model.DateInjection,
|
||||
ValidityPeriod = model.ValidityPeriod,
|
||||
UserId = model.UserId,
|
||||
User = context.Users
|
||||
.First(x => x.Id == model.UserId),
|
||||
@ -65,6 +66,8 @@ namespace VeterinaryClinicDatabaseImplement.Models
|
||||
|
||||
Name = model.Name;
|
||||
DateInjection = model.DateInjection;
|
||||
ValidityPeriod = model.ValidityPeriod;
|
||||
AnimalId = model.AnimalId;
|
||||
}
|
||||
|
||||
public VaccinationViewModel GetViewModel => new()
|
||||
@ -72,6 +75,7 @@ namespace VeterinaryClinicDatabaseImplement.Models
|
||||
Id = Id,
|
||||
Name = Name,
|
||||
DateInjection = DateInjection,
|
||||
ValidityPeriod = ValidityPeriod,
|
||||
UserId = UserId,
|
||||
UserFullName = User.FullName,
|
||||
AnimalId = Animal.Id,
|
||||
|
@ -1,37 +1,142 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Diagnostics;
|
||||
using VeterinaryClinicWebApp.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using VeterinaryClinicContracts.BindingModels;
|
||||
using VeterinaryClinicContracts.BusinessLogicsContracts;
|
||||
using VeterinaryClinicContracts.SearchModels;
|
||||
using VeterinaryClinicDataModels.Models;
|
||||
|
||||
namespace VeterinaryClinicWebApp.Controllers
|
||||
{
|
||||
public class AnimalController : Controller
|
||||
{
|
||||
private readonly ILogger<AnimalController> _logger;
|
||||
public AnimalController(ILogger<AnimalController> logger)
|
||||
|
||||
private readonly IAnimalLogic _animalLogic;
|
||||
|
||||
private readonly IMedicationLogic _medicationLogic;
|
||||
public AnimalController(ILogger<AnimalController> logger, IAnimalLogic animalLogic, IMedicationLogic medicationLogic)
|
||||
{
|
||||
_logger = logger;
|
||||
_animalLogic = animalLogic;
|
||||
_medicationLogic = medicationLogic;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Вывести список животных
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public IActionResult Animals()
|
||||
{
|
||||
return View();
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
return View(_animalLogic.ReadList(new AnimalSearchModel
|
||||
{
|
||||
UserId = APIClient.User.Id,
|
||||
}));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Создать животного
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public IActionResult CreateAnimal()
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.Medications = _medicationLogic.ReadList(null);
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult UpdateAnimal()
|
||||
[HttpPost]
|
||||
public void CreateAnimal(string type, string breed, int age, List<int> medication)
|
||||
{
|
||||
return View();
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public IActionResult Error()
|
||||
if (string.IsNullOrEmpty(type) || string.IsNullOrEmpty(breed) || age < 0 || medication == null)
|
||||
{
|
||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||
throw new Exception("Введены не все данные!");
|
||||
}
|
||||
|
||||
Dictionary<int, IMedicationModel> animalMedication = new Dictionary<int, IMedicationModel>();
|
||||
foreach (var medicationId in medication)
|
||||
{
|
||||
animalMedication.Add(medicationId, _medicationLogic.ReadElement(new MedicationSearchModel { Id = medicationId })!);
|
||||
}
|
||||
|
||||
_animalLogic.Create(new AnimalBindingModel
|
||||
{
|
||||
Type = type,
|
||||
Breed = breed,
|
||||
Age = age,
|
||||
AnimalMedications = animalMedication,
|
||||
UserId = APIClient.User.Id
|
||||
});
|
||||
|
||||
Response.Redirect("/Animal/Animals");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Редактировать животного
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public IActionResult UpdateAnimal(int id)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.Medications = _medicationLogic.ReadList(null);
|
||||
|
||||
return View(_animalLogic.ReadElement(new AnimalSearchModel
|
||||
{
|
||||
Id = id
|
||||
}));
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdateAnimal(int id, string type, string breed, int age, List<int> medication)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(type) || string.IsNullOrEmpty(breed) || age < 0 || medication == null)
|
||||
{
|
||||
throw new Exception("Введены не все данные!");
|
||||
}
|
||||
|
||||
Dictionary<int, IMedicationModel> animalMedication = new Dictionary<int, IMedicationModel>();
|
||||
foreach (var medicationId in medication)
|
||||
{
|
||||
animalMedication.Add(medicationId, _medicationLogic.ReadElement(new MedicationSearchModel { Id = medicationId })!);
|
||||
}
|
||||
|
||||
_animalLogic.Update(new AnimalBindingModel
|
||||
{
|
||||
Id = id,
|
||||
Type = type,
|
||||
Breed = breed,
|
||||
Age = age,
|
||||
AnimalMedications = animalMedication,
|
||||
UserId = APIClient.User.Id
|
||||
});
|
||||
|
||||
Response.Redirect("/Animal/Animals");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Удалить животного
|
||||
/// </summary>
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,9 @@
|
||||
using System.Diagnostics;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using VeterinaryClinicContracts.BindingModels;
|
||||
using VeterinaryClinicContracts.BusinessLogicsContracts;
|
||||
using VeterinaryClinicContracts.SearchModels;
|
||||
using VeterinaryClinicDataModels.Enums;
|
||||
using VeterinaryClinicWebApp.Models;
|
||||
|
||||
namespace VeterinaryClinicWebApp.Controllers;
|
||||
@ -8,30 +12,169 @@ public class HomeController : Controller
|
||||
{
|
||||
private readonly ILogger<HomeController> _logger;
|
||||
|
||||
public HomeController(ILogger<HomeController> logger)
|
||||
private readonly IUserLogic _userLogic;
|
||||
|
||||
public HomeController(ILogger<HomeController> logger, IUserLogic userLogic)
|
||||
{
|
||||
_logger = logger;
|
||||
_userLogic = userLogic;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Äîìàøíÿÿ ñòðàíèöà
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
return View(APIClient.User);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ëè÷íûå äàííûå ïîëüçîâàòåëÿ
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public IActionResult Privacy()
|
||||
{
|
||||
return View();
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
return View(APIClient.User);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Privacy(string fullname, UserRole role, string phone, string email, string password) {
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("Íåîáõîäèìî àâòîðèçîâàòüñÿ!");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(fullname) || string.IsNullOrEmpty(phone) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password))
|
||||
{
|
||||
throw new Exception("Ââåäåíû íå âñå äàííûå!");
|
||||
}
|
||||
|
||||
_userLogic.Update(new UserBindingModel
|
||||
{
|
||||
Id = APIClient.User.Id,
|
||||
FullName = fullname,
|
||||
Role = role,
|
||||
Phone = phone,
|
||||
Email = email,
|
||||
Password = password
|
||||
});
|
||||
|
||||
APIClient.User.FullName = fullname;
|
||||
APIClient.User.Role = role;
|
||||
APIClient.User.Phone = phone;
|
||||
APIClient.User.Email = email;
|
||||
APIClient.User.Password = password;
|
||||
|
||||
Response.Redirect("Privacy");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Àóòåíòèôèêàöèÿ
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public IActionResult Enter()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
public IActionResult Register()
|
||||
if (APIClient.User != null)
|
||||
{
|
||||
throw new Exception("Âû óæå àâòîðèçîâàëèñü!");
|
||||
}
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Enter(string email, string password)
|
||||
{
|
||||
if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password))
|
||||
{
|
||||
throw new Exception("Ââåäåíû íå âñå äàííûå!");
|
||||
}
|
||||
|
||||
APIClient.User = _userLogic.ReadElement(new UserSearchModel
|
||||
{
|
||||
Email = email,
|
||||
Password = password
|
||||
});
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("Íåâåðíûé ëîãèí/ïàðîëü");
|
||||
}
|
||||
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ðåãèñòðàöèÿ
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public IActionResult Register()
|
||||
{
|
||||
if (APIClient.User != null)
|
||||
{
|
||||
throw new Exception("Âû óæå çàðåãèñòðèðîâàëèñü!");
|
||||
}
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Register(string fullname, UserRole role, string phone, string email, string password)
|
||||
{
|
||||
if (string.IsNullOrEmpty(fullname) || string.IsNullOrEmpty(phone) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password))
|
||||
{
|
||||
throw new Exception("Ââåäåíû íå âñå äàííûå!");
|
||||
}
|
||||
|
||||
_userLogic.Create(new UserBindingModel
|
||||
{
|
||||
FullName = fullname,
|
||||
Role = role,
|
||||
Phone = phone,
|
||||
Email = email,
|
||||
Password = password
|
||||
});
|
||||
|
||||
Response.Redirect("Enter");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Âûéòè èç àêêàóíòà
|
||||
/// </summary>
|
||||
|
||||
/// <summary>
|
||||
/// Ïîëó÷èòü îò÷åò
|
||||
/// </summary>
|
||||
|
||||
/// <summary>
|
||||
/// Ñîçäàòü îò÷¸ò â ôîðìàòå Word
|
||||
/// </summary>
|
||||
|
||||
/// <summary>
|
||||
/// Ñîçäàòü îò÷¸ò â ôîðìàòå Excel
|
||||
/// </summary>
|
||||
|
||||
/// <summary>
|
||||
/// Ñîçäàòü îò÷¸ò â ôîðìàòå Pdf
|
||||
/// </summary>
|
||||
|
||||
/// <summary>
|
||||
/// Îòïðàâèòü ïî ïî÷òå îò÷¸ò
|
||||
/// </summary>
|
||||
|
||||
/// <summary>
|
||||
/// Îøèáêà
|
||||
/// </summary>
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public IActionResult Error()
|
||||
{
|
||||
|
@ -1,6 +1,9 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Diagnostics;
|
||||
using VeterinaryClinicContracts.BindingModels;
|
||||
using VeterinaryClinicContracts.BusinessLogicsContracts;
|
||||
using VeterinaryClinicContracts.SearchModels;
|
||||
using VeterinaryClinicWebApp.Models;
|
||||
|
||||
namespace VeterinaryClinicWebApp.Controllers
|
||||
@ -8,20 +11,107 @@ namespace VeterinaryClinicWebApp.Controllers
|
||||
public class MedicationController : Controller
|
||||
{
|
||||
private readonly ILogger<MedicationController> _logger;
|
||||
public MedicationController(ILogger<MedicationController> logger)
|
||||
|
||||
private readonly IMedicationLogic _medicationLogic;
|
||||
public MedicationController(ILogger<MedicationController> logger, IMedicationLogic medicationLogic)
|
||||
{
|
||||
_logger = logger;
|
||||
_medicationLogic = medicationLogic;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Вывести список лекарств
|
||||
/// </summary>
|
||||
public IActionResult Medications()
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
return View(_medicationLogic.ReadList(null));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Создать лекарство
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public IActionResult CreateMedication()
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public IActionResult Error()
|
||||
[HttpPost]
|
||||
public void CreateMedication(string name, string description)
|
||||
{
|
||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(description))
|
||||
{
|
||||
throw new Exception("Введены не все данные!");
|
||||
}
|
||||
|
||||
_medicationLogic.Create(new MedicationBindingModel
|
||||
{
|
||||
Name = name,
|
||||
Description = description
|
||||
});
|
||||
|
||||
Response.Redirect("/Medication/Medications");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Редактировать лекарство
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public IActionResult UpdateMedication(int id)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
return View(_medicationLogic.ReadElement(new MedicationSearchModel
|
||||
{
|
||||
Id = id
|
||||
}));
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdateMedication(int id, string name, string description)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(description))
|
||||
{
|
||||
throw new Exception("Введены не все данные!");
|
||||
}
|
||||
|
||||
_medicationLogic.Update(new MedicationBindingModel
|
||||
{
|
||||
Id = id,
|
||||
Name = name,
|
||||
Description = description
|
||||
});
|
||||
|
||||
Response.Redirect("/Medication/Medications");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Удалить лекарство
|
||||
/// </summary>
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,11 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Diagnostics;
|
||||
using VeterinaryClinicBusinessLogics.BusinessLogics;
|
||||
using VeterinaryClinicContracts.BindingModels;
|
||||
using VeterinaryClinicContracts.BusinessLogicsContracts;
|
||||
using VeterinaryClinicContracts.SearchModels;
|
||||
using VeterinaryClinicDataModels.Models;
|
||||
using VeterinaryClinicWebApp.Models;
|
||||
|
||||
namespace VeterinaryClinicWebApp.Controllers
|
||||
@ -8,20 +13,115 @@ namespace VeterinaryClinicWebApp.Controllers
|
||||
public class ServiceController : Controller
|
||||
{
|
||||
private readonly ILogger<ServiceController> _logger;
|
||||
public ServiceController(ILogger<ServiceController> logger)
|
||||
|
||||
private readonly IServiceLogic _serviceLogic;
|
||||
|
||||
private readonly IMedicationLogic _medicationLogic;
|
||||
public ServiceController(ILogger<ServiceController> logger, IServiceLogic serviceLogic, IMedicationLogic medicationLogic)
|
||||
{
|
||||
_logger = logger;
|
||||
_serviceLogic = serviceLogic;
|
||||
_medicationLogic = medicationLogic;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Вывести список животных
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public IActionResult Services()
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
return View(_serviceLogic.ReadList(null));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Создать животного
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public IActionResult CreateService()
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.Medications = _medicationLogic.ReadList(null);
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public IActionResult Error()
|
||||
[HttpPost]
|
||||
public void CreateService(string name, int cost, int medication)
|
||||
{
|
||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(name) || cost <= 0 || medication == 0)
|
||||
{
|
||||
throw new Exception("Введены не все данные!");
|
||||
}
|
||||
|
||||
_serviceLogic.Create(new ServiceBindingModel
|
||||
{
|
||||
Name = name,
|
||||
Cost = cost,
|
||||
MedicationId = medication
|
||||
});
|
||||
|
||||
Response.Redirect("/Service/Services");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Редактировать животного
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public IActionResult UpdateService(int id)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.Medications = _medicationLogic.ReadList(null);
|
||||
|
||||
return View(_serviceLogic.ReadElement(new ServiceSearchModel
|
||||
{
|
||||
Id = id
|
||||
}));
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdateService(int id, string name, int cost, int medication)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(name) || cost <= 0 || medication == 0)
|
||||
{
|
||||
throw new Exception("Введены не все данные!");
|
||||
}
|
||||
|
||||
_serviceLogic.Update(new ServiceBindingModel
|
||||
{
|
||||
Id = id,
|
||||
Name = name,
|
||||
Cost = cost,
|
||||
MedicationId = medication
|
||||
});
|
||||
|
||||
Response.Redirect("/Service/Services");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Удалить животного
|
||||
/// </summary>
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,13 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Diagnostics;
|
||||
using System.Xml.Linq;
|
||||
using VeterinaryClinicBusinessLogics.BusinessLogics;
|
||||
using VeterinaryClinicContracts.BindingModels;
|
||||
using VeterinaryClinicContracts.BusinessLogicsContracts;
|
||||
using VeterinaryClinicContracts.SearchModels;
|
||||
using VeterinaryClinicDatabaseImplement.Models;
|
||||
using VeterinaryClinicDataModels.Models;
|
||||
using VeterinaryClinicWebApp.Models;
|
||||
|
||||
namespace VeterinaryClinicWebApp.Controllers
|
||||
@ -8,20 +15,127 @@ namespace VeterinaryClinicWebApp.Controllers
|
||||
public class VaccinationController : Controller
|
||||
{
|
||||
private readonly ILogger<VaccinationController> _logger;
|
||||
public VaccinationController(ILogger<VaccinationController> logger)
|
||||
|
||||
private readonly IAnimalLogic _animalLogic;
|
||||
|
||||
private readonly IVaccinationLogic _vaccinationLogic;
|
||||
public VaccinationController(ILogger<VaccinationController> logger, IVaccinationLogic vaccinationLogic, IAnimalLogic animalLogic)
|
||||
{
|
||||
_logger = logger;
|
||||
_vaccinationLogic = vaccinationLogic;
|
||||
_animalLogic = animalLogic;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Вывести список вакцинаций
|
||||
/// </summary>
|
||||
public IActionResult Vaccinations()
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
return View(_vaccinationLogic.ReadList(new VaccinationSearchModel
|
||||
{
|
||||
UserId = APIClient.User.Id,
|
||||
}));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Создать животного
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public IActionResult CreateVaccination()
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.Animals = _animalLogic.ReadList(new AnimalSearchModel
|
||||
{
|
||||
UserId = APIClient.User.Id,
|
||||
});
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public IActionResult Error()
|
||||
[HttpPost]
|
||||
public void CreateVaccination(string name, DateTime dateInjection, string validityPeriod, int animal)
|
||||
{
|
||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(name) || dateInjection == DateTime.MinValue || string.IsNullOrEmpty(validityPeriod) || animal <= 0)
|
||||
{
|
||||
throw new Exception("Введены не все данные!");
|
||||
}
|
||||
|
||||
_vaccinationLogic.Create(new VaccinationBindingModel
|
||||
{
|
||||
Name = name,
|
||||
DateInjection = dateInjection,
|
||||
ValidityPeriod = validityPeriod,
|
||||
AnimalId = animal,
|
||||
UserId = APIClient.User.Id
|
||||
});
|
||||
|
||||
Response.Redirect("/Vaccination/Vaccinations");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Редактировать животного
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public IActionResult UpdateVaccination(int id)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.Animals = _animalLogic.ReadList(new AnimalSearchModel
|
||||
{
|
||||
UserId = APIClient.User.Id,
|
||||
});
|
||||
|
||||
return View(_vaccinationLogic.ReadElement(new VaccinationSearchModel
|
||||
{
|
||||
Id = id
|
||||
}));
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdateVaccination(int id, string name, DateTime dateInjection, string validityPeriod, int animal)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(name) || dateInjection == DateTime.MinValue || string.IsNullOrEmpty(validityPeriod) || animal <= 0)
|
||||
{
|
||||
throw new Exception("Введены не все данные!");
|
||||
}
|
||||
|
||||
_vaccinationLogic.Update(new VaccinationBindingModel
|
||||
{
|
||||
Id = id,
|
||||
Name = name,
|
||||
DateInjection = dateInjection,
|
||||
ValidityPeriod = validityPeriod,
|
||||
AnimalId = animal,
|
||||
UserId = APIClient.User.Id
|
||||
});
|
||||
|
||||
Response.Redirect("/Vaccination/Vaccinations");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Удалить животного
|
||||
/// </summary>
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,7 @@
|
||||
using VeterinaryClinicBusinessLogics.BusinessLogics;
|
||||
using VeterinaryClinicContracts.BusinessLogicsContracts;
|
||||
using VeterinaryClinicContracts.StoragesContracts;
|
||||
using VeterinaryClinicDatabaseImplement.Implements;
|
||||
using VeterinaryClinicWebApp;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
@ -5,6 +9,29 @@ var builder = WebApplication.CreateBuilder(args);
|
||||
// Add services to the container.
|
||||
builder.Services.AddControllersWithViews();
|
||||
|
||||
builder.Logging.SetMinimumLevel(LogLevel.Trace);
|
||||
|
||||
builder.Services.AddTransient<IAnimalStorage, AnimalStorage>();
|
||||
builder.Services.AddTransient<IMedicationStorage, MedicationStorage>();
|
||||
builder.Services.AddTransient<IServiceStorage, ServiceStorage>();
|
||||
builder.Services.AddTransient<IUserStorage, UserStorage>();
|
||||
builder.Services.AddTransient<IVaccinationStorage, VaccinationStorage>();
|
||||
builder.Services.AddTransient<IVisitStorage, VisitStorage>();
|
||||
|
||||
builder.Services.AddTransient<IAnimalLogic, AnimalLogic>();
|
||||
builder.Services.AddTransient<IMedicationLogic, MedicationLogic>();
|
||||
builder.Services.AddTransient<IServiceLogic, ServiceLogic>();
|
||||
builder.Services.AddTransient<IUserLogic, UserLogic>();
|
||||
builder.Services.AddTransient<IVaccinationLogic, VaccinationLogic>();
|
||||
builder.Services.AddTransient<IVisitLogic, VisitLogic>();
|
||||
|
||||
builder.Services.AddSession(options =>
|
||||
{
|
||||
options.IdleTimeout = TimeSpan.FromMinutes(30);
|
||||
options.Cookie.HttpOnly = true;
|
||||
options.Cookie.IsEssential = true;
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
APIClient.Connect(builder.Configuration);
|
||||
|
@ -31,6 +31,8 @@
|
||||
<th>Порода</th>
|
||||
<th>Возраст</th>
|
||||
<th>Пользователь</th>
|
||||
<th>Назначенные лекарства</th>
|
||||
<th>Действия</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@ -38,15 +40,28 @@
|
||||
@foreach (var animal in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>@Html.DisplayFor(modelItem => animal.Id)</td>
|
||||
<td>@Html.DisplayFor(modelItem => animal.Type)</td>
|
||||
<td>@Html.DisplayFor(modelItem => animal.Breed)</td>
|
||||
<td>@Html.DisplayFor(modelItem => animal.Age)</td>
|
||||
<td>@Html.DisplayFor(modelItem => animal.UserFullName)</td>
|
||||
<th>@animal.Id</th>
|
||||
<td>@animal.Type</td>
|
||||
<td>@animal.Breed</td>
|
||||
<td>@animal.Age</td>
|
||||
<td>@animal.UserFullName</td>
|
||||
<td>
|
||||
<p><button type="button" class="btn btn-primary" onclick="location.href='@Url.Action("UpdateAnimal", "/Animal", new { id = animal.Id })'">Изменить</button></p>
|
||||
@if (animal.AnimalMedications.Any())
|
||||
{
|
||||
<ul>
|
||||
@foreach (var medication in animal.AnimalMedications)
|
||||
{
|
||||
<li>@medication.Value.Name</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p>Нет назначенных лекарств</p>
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
<p><button type="button" class="btn btn-primary" onclick="location.href='@Url.Action("UpdateAnimal", "/Animal", new { id = animal.Id })'">Изменить</button></p>
|
||||
<p><button type="button" class="btn btn-primary" onclick="deleteAnimal(@animal.Id)">Удалить</button></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -24,14 +24,14 @@
|
||||
<div class="col-8"><input type="text" name="Age" id="Age" /></div>
|
||||
</div>
|
||||
|
||||
<!-- Пользователь -->
|
||||
<!-- Медикаменты -->
|
||||
<div class="row">
|
||||
<div class="col-4">Медикаменты:</div>
|
||||
<div class="col-8">
|
||||
<select name="medication" id="medication" class="form-control">
|
||||
<select name="medications" id="medications" class="form-control" size="4" multiple>
|
||||
@foreach (var medication in ViewBag.Medications)
|
||||
{
|
||||
<option value="@medication.Name"></option>
|
||||
<option value="@medication.Id">@medication.Name</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
|
@ -34,7 +34,7 @@
|
||||
<div class="row">
|
||||
<div class="col-4">Медикаменты:</div>
|
||||
<div class="col-8">
|
||||
<select name="medication" id="medication" class="form-control" size="4" multiple>
|
||||
<select name="medications" id="medications" class="form-control" multiple>
|
||||
@foreach (var medication in ViewBag.Medications)
|
||||
{
|
||||
var isSelected = Model.AnimalMedications.Any(x => x.Key.Equals(medication.Id));
|
||||
|
@ -3,5 +3,5 @@
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Welcome to my progect</h1>
|
||||
<h1 class="display-4">Welcome to my project</h1>
|
||||
</div>
|
||||
|
@ -0,0 +1,27 @@
|
||||
@{
|
||||
ViewData["Title"] = "Создание медикамента";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Создание медикамента</h2>
|
||||
</div>
|
||||
|
||||
<form method="post" style="margin-top: 50px">
|
||||
<!-- Наименование -->
|
||||
<div class="row">
|
||||
<div class="col-4">Наименование:</div>
|
||||
<div class="col-8"><input type="text" name="name" id="name" /></div>
|
||||
</div>
|
||||
|
||||
<!-- Описание -->
|
||||
<div class="row">
|
||||
<div class="col-4">Описание:</div>
|
||||
<div class="col-8"><input type="text" name="description" id="description" /></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>
|
@ -28,6 +28,7 @@
|
||||
<th>Номер</th>
|
||||
<th>Название</th>
|
||||
<th>Описание</th>
|
||||
<th>Действия</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@ -40,8 +41,6 @@
|
||||
<td>@Html.DisplayFor(modelItem => medication.Description)</td>
|
||||
<td>
|
||||
<p><button type="button" class="btn btn-primary" onclick="location.href='@Url.Action("UpdateMedication", "/Medication", new { id = medication.Id })'">Изменить</button></p>
|
||||
</td>
|
||||
<td>
|
||||
<p><button type="button" class="btn btn-primary" onclick="deleteMedication(@medication.Id)">Удалить</button></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -0,0 +1,32 @@
|
||||
|
||||
@using VeterinaryClinicContracts.ViewModels
|
||||
|
||||
@model MedicationViewModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Редактирование медикамента";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Редактирование медикамента</h2>
|
||||
</div>
|
||||
|
||||
<form method="post" style="margin-top: 50px">
|
||||
<!-- Наименование -->
|
||||
<div class="row">
|
||||
<div class="col-4">Наименование:</div>
|
||||
<div class="col-8"><input type="text" name="name" value="@Model.Name" /></div>
|
||||
</div>
|
||||
|
||||
<!-- Описание -->
|
||||
<div class="row">
|
||||
<div class="col-4">Описание:</div>
|
||||
<div class="col-8"><input type="text" class="form-control" name="description" value="@Model.Description" /></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>
|
@ -0,0 +1,40 @@
|
||||
@{
|
||||
ViewData["Title"] = "Создание услуги";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Создание услуги</h2>
|
||||
</div>
|
||||
|
||||
<form method="post" style="margin-top: 50px">
|
||||
<!-- Наименование -->
|
||||
<div class="row">
|
||||
<div class="col-4">Наименование:</div>
|
||||
<div class="col-8"><input type="text" name="name" id="name" /></div>
|
||||
</div>
|
||||
|
||||
<!-- Стоимость -->
|
||||
<div class="row">
|
||||
<div class="col-4">Цена:</div>
|
||||
<div class="col-8"><input type="int" name="cost" id="cost" /></div>
|
||||
</div>
|
||||
|
||||
<!-- Медикаменты -->
|
||||
<div class="row">
|
||||
<div class="col-4">Медикамент:</div>
|
||||
<div class="col-8">
|
||||
<select name="medication" id="medication" class="form-control">
|
||||
@foreach (var medication in ViewBag.Medications)
|
||||
{
|
||||
<option value="@medication.Id">@medication.Name</option>
|
||||
}
|
||||
</select>
|
||||
</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>
|
@ -29,6 +29,7 @@
|
||||
<th>Название</th>
|
||||
<th>Цена</th>
|
||||
<th>Медикамент</th>
|
||||
<th>Действия</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@ -42,8 +43,6 @@
|
||||
<td>@Html.DisplayFor(modelItem => service.MedicationName)</td>
|
||||
<td>
|
||||
<p><button type="button" class="btn btn-primary" onclick="location.href='@Url.Action("UpdateService", "/Service", new { id = service.Id })'">Изменить</button></p>
|
||||
</td>
|
||||
<td>
|
||||
<p><button type="button" class="btn btn-primary" onclick="deleteService(@service.Id)">Удалить</button></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -0,0 +1,46 @@
|
||||
|
||||
@using VeterinaryClinicContracts.ViewModels
|
||||
|
||||
@model ServiceViewModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Редактирование услуги";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Редактирование услуги</h2>
|
||||
</div>
|
||||
|
||||
<form method="post" style="margin-top: 50px">
|
||||
<!-- Наименование -->
|
||||
<div class="row">
|
||||
<div class="col-4">Наименование:</div>
|
||||
<div class="col-8"><input type="text" name="name" value="@Model.Name" /></div>
|
||||
</div>
|
||||
|
||||
<!-- Стоимость -->
|
||||
<div class="row">
|
||||
<div class="col-4">Стоимость:</div>
|
||||
<div class="col-8"><input type="int" class="form-control" name="cost" value="@Model.Cost" /></div>
|
||||
</div>
|
||||
|
||||
<!-- Медикамент -->
|
||||
<div class="row">
|
||||
<div class="col-4">Медикамент:</div>
|
||||
<div class="col-8">
|
||||
<select name="medication" id="medication" class="form-control">
|
||||
@foreach (var medication in ViewBag.Medications)
|
||||
{
|
||||
var isSelected = medication.Id == Model.MedicationId;
|
||||
<option value="@medication.Id" selected="@isSelected" >@medication.Name</option>
|
||||
}
|
||||
</select>
|
||||
</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>
|
@ -11,7 +11,7 @@
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bgwhite border-bottom box-shadow mb-3">
|
||||
<div class="container">
|
||||
<a class="navbar-brand" asp-area="" asp-controller="Home" aspaction="Index">Айболит</a>
|
||||
<a class="navbar-brand" asparea="" asp-controller="Home" asp-action="Index">Айболит</a>
|
||||
<button class="navbar-toggler" type="button" datatoggle="collapse" data-target=".navbar-collapse" ariacontrols="navbarSupportedContent"
|
||||
aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
@ -66,7 +66,7 @@
|
||||
</div>
|
||||
<footer class="border-top footer text-muted">
|
||||
<div class="container">
|
||||
© 2024 - Айболит - <a asp-area="" aspcontroller="Home" asp-action="Privacy">Privacy</a>
|
||||
© 2024 - Айболит - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
|
@ -0,0 +1,46 @@
|
||||
@{
|
||||
ViewData["Title"] = "Создание услуги";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Создание услуги</h2>
|
||||
</div>
|
||||
|
||||
<form method="post" style="margin-top: 50px">
|
||||
<!-- Наименование -->
|
||||
<div class="row">
|
||||
<div class="col-4">Наименование:</div>
|
||||
<div class="col-8"><input type="text" name="name" id="name" /></div>
|
||||
</div>
|
||||
|
||||
<!-- Дата укола -->
|
||||
<div class="row">
|
||||
<div class="col-4">Дата укола:</div>
|
||||
<div class="col-8"><input type="date" class="form-control" name="dateInjection" id="dateInjection" /></div>
|
||||
</div>
|
||||
|
||||
<!-- Период действия -->
|
||||
<div class="row">
|
||||
<div class="col-4">Период действия:</div>
|
||||
<div class="col-8"><input type="text" name="validityPeriod" id="validityPeriod" /></div>
|
||||
</div>
|
||||
|
||||
<!-- Животное -->
|
||||
<div class="row">
|
||||
<div class="col-4">Животное:</div>
|
||||
<div class="col-8">
|
||||
<select name="animal" id="animal" class="form-control">
|
||||
@foreach (var animal in ViewBag.Animals)
|
||||
{
|
||||
<option value="@animal.Id">@animal.Breed</option>
|
||||
}
|
||||
</select>
|
||||
</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>
|
@ -0,0 +1,52 @@
|
||||
|
||||
@using VeterinaryClinicContracts.ViewModels
|
||||
|
||||
@model VaccinationViewModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Редактирование вакцинации";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Редактирование вакцинации</h2>
|
||||
</div>
|
||||
|
||||
<form method="post" style="margin-top: 50px">
|
||||
<!-- Наименование -->
|
||||
<div class="row">
|
||||
<div class="col-4">Наименование:</div>
|
||||
<div class="col-8"><input type="text" name="name" value="@Model.Name" /></div>
|
||||
</div>
|
||||
|
||||
<!-- Дата укола -->
|
||||
<div class="row">
|
||||
<div class="col-4">Дата укола:</div>
|
||||
<div class="col-8"><input type="date" class="form-control" name="dateInjection" value="@Model.DateInjection.ToString("yyyy-MM-dd")" /></div>
|
||||
</div>
|
||||
|
||||
<!-- Период действия -->
|
||||
<div class="row">
|
||||
<div class="col-4">Период действия:</div>
|
||||
<div class="col-8"><input type="text" name="validityPeriod" value="@Model.ValidityPeriod" /></div>
|
||||
</div>
|
||||
|
||||
<!-- Животное -->
|
||||
<div class="row">
|
||||
<div class="col-4">Животное:</div>
|
||||
<div class="col-8">
|
||||
<select name="animal" id="animal" class="form-control">
|
||||
@foreach (var animal in ViewBag.Animals)
|
||||
{
|
||||
var isSelected = animal.Id == Model.AnimalId;
|
||||
<option value="@animal.Id" selected="@isSelected">@animal.Breed</option>
|
||||
}
|
||||
</select>
|
||||
</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>
|
@ -30,6 +30,7 @@
|
||||
<th>Порода животного</th>
|
||||
<th>Срок действия прививки</th>
|
||||
<th>Дата укола</th>
|
||||
<th>Действия</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@ -41,11 +42,9 @@
|
||||
<td>@Html.DisplayFor(modelItem => vaccination.Name)</td>
|
||||
<td>@Html.DisplayFor(modelItem => vaccination.AnimalBreed)</td>
|
||||
<td>@Html.DisplayFor(modelItem => vaccination.ValidityPeriod)</td>
|
||||
<td>@Html.DisplayFor(modelItem => vaccination.DateInjection.ToShortDateString())</td>
|
||||
<td>@Html.DisplayFor(modelItem => vaccination.DateInjection)</td>
|
||||
<td>
|
||||
<p><button type="button" class="btn btn-primary" onclick="location.href='@Url.Action("UpdateVaccination", "/Vaccination", new { id = vaccination.Id })'">Изменить</button></p>
|
||||
</td>
|
||||
<td>
|
||||
<p><button type="button" class="btn btn-primary" onclick="deleteVaccination(@vaccination.Id)">Удалить</button></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
Loading…
Reference in New Issue
Block a user