┐(シ)┌ фиксы

This commit is contained in:
Софья Якобчук 2024-05-03 02:48:53 +04:00
parent cc6e66ef00
commit 22f02bc6bb
9 changed files with 13 additions and 16 deletions

View File

@ -8,6 +8,6 @@ namespace LawCompanyContracts.BindingModels
public string FIO { get; set; } = string.Empty; public string FIO { get; set; } = string.Empty;
public string Phone { get; set; } = string.Empty; public string Phone { get; set; } = string.Empty;
public string Email { get; set; } = string.Empty; public string Email { get; set; } = string.Empty;
public int GuarantorId { get; set; } public int? GuarantorId { get; set; }
} }
} }

View File

@ -13,6 +13,6 @@ namespace LawCompanyContracts.ViewModels
public string Phone { get; set; } = string.Empty; public string Phone { get; set; } = string.Empty;
[DisplayName("E-mail юриста")] [DisplayName("E-mail юриста")]
public string Email { get; set; } = string.Empty; public string Email { get; set; } = string.Empty;
public int GuarantorId { get; set; } public int? GuarantorId { get; set; }
} }
} }

View File

@ -7,6 +7,6 @@ namespace LawCompanyDataModels.Models
string FIO { get; } string FIO { get; }
string Phone { get; } string Phone { get; }
string Email { get; } string Email { get; }
public int GuarantorId { get; } public int? GuarantorId { get; }
} }
} }

View File

@ -59,7 +59,7 @@ namespace LawCompanyDatabaseImplement.Implements
public GuarantorViewModel? Insert(GuarantorBindingModel model) public GuarantorViewModel? Insert(GuarantorBindingModel model)
{ {
using var context = new LawCompanyDatabase(); using var context = new LawCompanyDatabase();
var newGuarantor = Guarantor.Create(model); var newGuarantor = Guarantor.Create(context, model);
if (newGuarantor == null) if (newGuarantor == null)
{ {
return null; return null;

View File

@ -61,7 +61,7 @@ namespace LawCompanyDatabaseImplement.Implements
public LawyerViewModel? Insert(LawyerBindingModel model) public LawyerViewModel? Insert(LawyerBindingModel model)
{ {
using var context = new LawCompanyDatabase(); using var context = new LawCompanyDatabase();
var newLawyer = Lawyer.Create(model); var newLawyer = Lawyer.Create(context, model);
if (newLawyer == null) if (newLawyer == null)
{ {
return null; return null;

View File

@ -15,7 +15,7 @@ namespace LawCompanyDatabaseImplement
{ {
if (optionsBuilder.IsConfigured == false) if (optionsBuilder.IsConfigured == false)
{ {
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-H8060U3\SQLEXPRESS;Initial Catalog=LawCompanyDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); optionsBuilder.UseSqlServer(@"Data Source=LAPTOP-6GNIALH9\SQLEXPRESS;Initial Catalog=LawCompanyDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
} }
base.OnConfiguring(optionsBuilder); base.OnConfiguring(optionsBuilder);
} }

View File

@ -22,8 +22,7 @@ namespace LawCompanyDatabaseImplement.Models
public virtual List<Lawyer> Lawyers { get; set; } = new(); public virtual List<Lawyer> Lawyers { get; set; } = new();
[ForeignKey("GuarantorId")] [ForeignKey("GuarantorId")]
public virtual List<Consultation> Consultations { get; set; } = new(); public virtual List<Consultation> Consultations { get; set; } = new();
public static Guarantor? Create(LawCompanyDatabase context, GuarantorBindingModel? model)
public static Guarantor? Create(GuarantorBindingModel? model)
{ {
if (model == null) if (model == null)
{ {

View File

@ -1,12 +1,9 @@
using LawCompanyContracts.BindingModels; using LawCompanyContracts.BindingModels;
using LawCompanyContracts.ViewModels; using LawCompanyContracts.ViewModels;
using LawCompanyDataModels.Models; using LawCompanyDataModels.Models;
using LawCompanyDataModels.Models;
using LawCompanyContracts.BindingModels;
using LawCompanyContracts.ViewModels;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.Design;
namespace LawCompanyDatabaseImplement.Models namespace LawCompanyDatabaseImplement.Models
{ {
@ -23,9 +20,9 @@ namespace LawCompanyDatabaseImplement.Models
public virtual List<HearingLawyer> HearingLawyers { get; set; } = new(); public virtual List<HearingLawyer> HearingLawyers { get; set; } = new();
[ForeignKey("LawyerId")] [ForeignKey("LawyerId")]
public virtual List<ConsultationLawyer> ConsultationLawyers { get; set; } = new(); public virtual List<ConsultationLawyer> ConsultationLawyers { get; set; } = new();
public int GuarantorId { get; set; } public int? GuarantorId { get; set; }
public static Lawyer? Create(LawyerBindingModel? model) public static Lawyer? Create(LawCompanyDatabase context, LawyerBindingModel? model)
{ {
if (model == null) if (model == null)
{ {
@ -60,6 +57,7 @@ namespace LawCompanyDatabaseImplement.Models
FIO = model.FIO; FIO = model.FIO;
Email = model.Email; Email = model.Email;
Phone = model.Phone; Phone = model.Phone;
if (!model.GuarantorId.HasValue) GuarantorId = model.GuarantorId;
} }
public LawyerViewModel GetViewModel => new() public LawyerViewModel GetViewModel => new()
{ {

View File

@ -20,7 +20,7 @@ builder.Services.AddTransient<ILawyerStorage, LawyerStorage>();
builder.Services.AddTransient<IHearingStorage, HearingStorage>(); builder.Services.AddTransient<IHearingStorage, HearingStorage>();
builder.Services.AddTransient<IExecutorStorage, ExecutorStorage>(); builder.Services.AddTransient<IExecutorStorage, ExecutorStorage>();
//builder.Services.AddTransient<IGuarantorStorage, GuarantorStorage>(); builder.Services.AddTransient<IGuarantorStorage, GuarantorStorage>();
builder.Services.AddTransient<ICaseLogic, CaseLogic>(); builder.Services.AddTransient<ICaseLogic, CaseLogic>();
@ -32,7 +32,7 @@ builder.Services.AddTransient<IHearingLogic, HearingLogic>();
builder.Services.AddTransient<ILawyerLogic, LawyerLogic>(); builder.Services.AddTransient<ILawyerLogic, LawyerLogic>();
builder.Services.AddTransient<IExecutorLogic, ExecutorLogic>(); builder.Services.AddTransient<IExecutorLogic, ExecutorLogic>();
//builder.Services.AddTransient<IGuarantorLogic, GuarantorLogic>(); builder.Services.AddTransient<IGuarantorLogic, GuarantorLogic>();
builder.Services.AddControllers(); builder.Services.AddControllers();