что-то сделал

This commit is contained in:
goblinrf 2024-04-23 23:47:00 +04:00
parent cff2dbca9e
commit ae806f04b4
12 changed files with 81 additions and 26 deletions

View File

@ -18,7 +18,7 @@ namespace VetClinicDataBaseImplement.Models
[Required]
public int AdminId { get; set; }
[Required]
public int VisitId { get; set; }
public List<IVisitModel>? _visitAnimals = null;
[Required]
public string AnimalName { get; set; }= string.Empty;
@ -27,16 +27,26 @@ namespace VetClinicDataBaseImplement.Models
//public virtual Visit Visit { get; set; }
public virtual Admin Admin { get; set; }
//public virtual Visut Visit { get; set; }
public virtual Visit Visit { get; set; }
//public virtual Vaccination Vaccination { get; set; }
// [ForeignKey("AnimalId")]
//public virtual List<Visit> Visits { get; set; } = new();
[ForeignKey("AnimalId")]
public virtual List<VisitAnimal> Visits { get; set; } = new();
//[ForeignKey("AnimalId")]
//public virtual List<Vaccination> Vaccinations { get; set; } = new();
public static Animal? Create(AnimalBindingModel? model)
public List<IVisitModel> VisitAnimals
{
get
{
if (_visitAnimals == null)
{
_visitAnimals = Visits.Select(recPC => recPC.Visit as IVisitModel).ToList();
}
return _visitAnimals;
}
}
public static Animal? Create(VetClinicDatabase context, AnimalBindingModel? model)
{
if (model == null)
{
@ -45,7 +55,10 @@ namespace VetClinicDataBaseImplement.Models
return new Animal()
{
Id = model.Id,
VisitId = model.VisitId,
Visits = model.VisitAnimals.Select(x => new VisitAnimal
{
Id = x.Id
}).ToList(),
AdminId = model.AdminId,
//VaccinationId = model.VaccinationId
AnimalName = model.AnimalName,
@ -65,7 +78,7 @@ namespace VetClinicDataBaseImplement.Models
public AnimalViewModel GetViewModel => new()
{
Id = Id,
VisitId = VisitId,
VisitAnimals = VisitAnimals,
AdminId = AdminId,
//VaccinationId = VaccinationId
AnimalName = AnimalName,

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VetClinicDataBaseImplement.Models
{
public class Visit
{
}
}

View File

@ -0,0 +1,24 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VetClinicDataBaseImplement.Models;
namespace VetClinicDataBaseImplement.Models
{
public class VisitAnimal
{
public int Id { get; set; }
[Required]
public int AnimalId { get; set; }
[Required]
public int VisittId { get; set; }
public virtual Animal Animal { get; set; } = new();
public virtual Visit Visit { get; set; } = new();
}
}

View File

@ -1,6 +1,8 @@
using VetClinicDataBaseImplement.Models;
using Microsoft.EntityFrameworkCore;
namespace VetClinicDataBaseImplement
{
public class VetClinicDatabase : DbContext
@ -15,7 +17,8 @@ namespace VetClinicDataBaseImplement
}
public virtual DbSet<Animal> Animals { set; get; }
public virtual DbSet<Admin> Admins { set; get; }
// public virtual DbSet<Visit> Visits { set; get; }
// public virtual DbSet<Vaccination> Vaccinations { set; get; }
}
public virtual DbSet<VisitAnimal> VisitAnimals { set; get; }
public virtual DbSet<Visit> Visits { set; get; }
// public virtual DbSet<Vaccination> Vaccinations { set; get; }
}
}

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VetClinicDataModels.Models;
namespace VetClinicContracts.BindingModels
{
@ -10,7 +11,7 @@ namespace VetClinicContracts.BindingModels
{
public int Id { get; set; }
public int AdminId { get; set; }
public int VisitId { get; set; }
public List<IVisitModel> VisitAnimals { get; set; } = new();
public string AnimalName { get; set; } = string.Empty;
public string? Family { get; set; } = string.Empty;

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VetClinicDataModels.Models;
namespace VetClinicContracts.SearchModels
{
@ -11,7 +12,7 @@ namespace VetClinicContracts.SearchModels
public int? Id { get; set; }
public int? AdminId { get; set; }
public int? VisitId { get; set; }
public List<IVisitModel> Visits { get; set; } = new();
public string? AnimalName { get; set; }

View File

@ -13,7 +13,7 @@ namespace VetClinicContracts.ViewModels
public int Id { get; set; }
public int AdminId { get; set; }
public int VisitId { get; set; }
public List<IVisitModel> VisitAnimals { get; set; } = new();
[DisplayName("Имя животного")]
public string AnimalName { get; set; } = string.Empty;

View File

@ -22,5 +22,6 @@ namespace VetClinicContracts.ViewModels
[DisplayName("Дата визита")]
public DateTime DateVisit { get; set; }
}
public List<IAnimalModel> VisitAnimals { get; set; } = new();
}
}

View File

@ -1,8 +1,8 @@

namespace VetClinicDataModels.Models
{
public interface IAdminModel
{
public interface IAdminModel : IId
{
string AdminFIO { get; }
string Email { get; }
string Password { get; }

View File

@ -6,10 +6,10 @@ using System.Threading.Tasks;
namespace VetClinicDataModels.Models
{
public interface IAnimalModel
{
public interface IAnimalModel : IId
{
int AdminId { get; }
int VisitId { get; }
List <IVisitModel> VisitAnimals { get; }
string AnimalName { get; }
string? Family { get; }
}

View File

@ -6,8 +6,8 @@ using System.Threading.Tasks;
namespace VetClinicDataModels.Models
{
public interface IVaccinationModel
{
public interface IVaccinationModel : IId
{
int AnimalId { get; }
string NameVaccination { get; }

View File

@ -6,13 +6,13 @@ using System.Threading.Tasks;
namespace VetClinicDataModels.Models
{
public interface IVisitModel
{
public interface IVisitModel : IId
{
int Id { get;}
int ServiceId { get; }
int AdminId { get; }
string NameVisit { get;}
DateTime DateVisit { get; }
}
List<IAnimalModel> VisitAnimals { get; }
}
}