laba8
This commit is contained in:
parent
aecb2bdf42
commit
fdd0cd0433
BIN
ImplementationExtensions/PlumbingRepairContracts.dll
Normal file
BIN
ImplementationExtensions/PlumbingRepairContracts.dll
Normal file
Binary file not shown.
BIN
ImplementationExtensions/PlumbingRepairDataModels.dll
Normal file
BIN
ImplementationExtensions/PlumbingRepairDataModels.dll
Normal file
Binary file not shown.
BIN
ImplementationExtensions/PlumbingRepairDatabaseImplement.dll
Normal file
BIN
ImplementationExtensions/PlumbingRepairDatabaseImplement.dll
Normal file
Binary file not shown.
BIN
ImplementationExtensions/PlumbingRepairFileImplement.dll
Normal file
BIN
ImplementationExtensions/PlumbingRepairFileImplement.dll
Normal file
Binary file not shown.
@ -22,6 +22,7 @@
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\PlumbingRepairBusinessLogic\PlumbingRepairBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\PlumbingRepairContracts\PlumbingRepairContracts.csproj" />
|
||||
<ProjectReference Include="..\PlumbingRepairDatabaseImplement\PlumbingRepairDatabaseImplement.csproj" />
|
||||
<ProjectReference Include="..\PlumbingRepairListImplement\PlumbingRepairListImplement.csproj" />
|
||||
<ProjectReference Include="..\PlumpingRepairFileImplement\PlumbingRepairFileImplement.csproj" />
|
||||
</ItemGroup>
|
||||
|
@ -0,0 +1,22 @@
|
||||
using PlumbingRepairContracts.DI;
|
||||
using PlumbingRepairContracts.StoragesContracts;
|
||||
using PlumbingRepairDatabaseImplement.Implements;
|
||||
|
||||
namespace PlumbingRepairDatabaseImplement
|
||||
{
|
||||
public class DatabaseImplementationExtension : IImplementationExtension
|
||||
{
|
||||
public int Priority => 2;
|
||||
|
||||
public void RegisterServices()
|
||||
{
|
||||
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
|
||||
DependencyManager.Instance.RegisterType<IComponentStorage, ComponentStorage>();
|
||||
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
|
||||
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
|
||||
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
|
||||
DependencyManager.Instance.RegisterType<IWorkStorage, WorkStorage>();
|
||||
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
||||
}
|
||||
}
|
||||
}
|
29
PlumbingRepairDatabaseImplement/Implements/BackUpInfo.cs
Normal file
29
PlumbingRepairDatabaseImplement/Implements/BackUpInfo.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using PlumbingRepairContracts.StoragesContracts;
|
||||
|
||||
namespace PlumbingRepairDatabaseImplement.Implements
|
||||
{
|
||||
public class BackUpInfo : IBackUpInfo
|
||||
{
|
||||
public List<T>? GetList<T>() where T : class, new()
|
||||
{
|
||||
using var context = new PlumbingRepairDataBase();
|
||||
return context.Set<T>().ToList();
|
||||
}
|
||||
|
||||
public Type? GetTypeByModelInterface(string modelInterfaceName)
|
||||
{
|
||||
var assembly = typeof(BackUpInfo).Assembly;
|
||||
var types = assembly.GetTypes();
|
||||
|
||||
foreach (var type in types)
|
||||
{
|
||||
if (type.IsClass && type.GetInterface(modelInterfaceName) != null)
|
||||
{
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -12,7 +12,7 @@ using PlumbingRepairDatabaseImplement;
|
||||
namespace PlumbingRepairDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(PlumbingRepairDataBase))]
|
||||
[Migration("20231108203013_init")]
|
||||
[Migration("20231122235359_init")]
|
||||
partial class init
|
||||
{
|
||||
/// <inheritdoc />
|
||||
@ -223,7 +223,7 @@ namespace PlumbingRepairDatabaseImplement.Migrations
|
||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Message", b =>
|
||||
{
|
||||
b.HasOne("PlumbingRepairDatabaseImplement.Models.Client", "Client")
|
||||
.WithMany()
|
||||
.WithMany("Messages")
|
||||
.HasForeignKey("ClientId");
|
||||
|
||||
b.Navigation("Client");
|
||||
@ -275,6 +275,8 @@ namespace PlumbingRepairDatabaseImplement.Migrations
|
||||
|
||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Navigation("Messages");
|
||||
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
@ -220,7 +220,7 @@ namespace PlumbingRepairDatabaseImplement.Migrations
|
||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Message", b =>
|
||||
{
|
||||
b.HasOne("PlumbingRepairDatabaseImplement.Models.Client", "Client")
|
||||
.WithMany()
|
||||
.WithMany("Messages")
|
||||
.HasForeignKey("ClientId");
|
||||
|
||||
b.Navigation("Client");
|
||||
@ -272,6 +272,8 @@ namespace PlumbingRepairDatabaseImplement.Migrations
|
||||
|
||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Navigation("Messages");
|
||||
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
|
@ -3,18 +3,24 @@ using PlumbingRepairContracts.ViewModels;
|
||||
using PlumbingRepairDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace PlumbingRepairDatabaseImplement.Models
|
||||
{
|
||||
public class Client : IClientModel
|
||||
[DataContract]
|
||||
public class Client : IClientModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DataMember]
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
[DataMember]
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
[DataMember]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
[DataMember]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
[ForeignKey("ClientId")]
|
||||
public virtual List<Order> Orders { get; set; } = new();
|
||||
[ForeignKey("ClientId")]
|
||||
|
@ -3,18 +3,23 @@ using PlumbingRepairContracts.ViewModels;
|
||||
using PlumbingRepairDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace PlumbingRepairDatabaseImplement.Models
|
||||
{
|
||||
public class Component : IComponentModel
|
||||
[DataContract]
|
||||
public class Component : IComponentModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
[DataMember]
|
||||
public int Id { get; private set; }
|
||||
|
||||
[Required]
|
||||
public string ComponentName { get; private set; } = string.Empty;
|
||||
[DataMember]
|
||||
public string ComponentName { get; private set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public double Cost { get; set; }
|
||||
[DataMember]
|
||||
public double Cost { get; set; }
|
||||
|
||||
[ForeignKey("ComponentId")]
|
||||
public virtual List<WorkComponent> WorkComponents { get; set; } = new();
|
||||
|
@ -3,23 +3,30 @@ using PlumbingRepairContracts.ViewModels;
|
||||
using PlumbingRepairDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace PlumbingRepairDatabaseImplement.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class Implementer : IImplementerModel
|
||||
{
|
||||
[DataMember]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[DataMember]
|
||||
public string ImplementerFIO { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
[DataMember]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
[DataMember]
|
||||
public int WorkExperience { get; set; }
|
||||
|
||||
[Required]
|
||||
[DataMember]
|
||||
public int Qualification { get; set; }
|
||||
|
||||
[ForeignKey("ImplementerId")]
|
||||
|
@ -2,17 +2,25 @@
|
||||
using PlumbingRepairContracts.ViewModels;
|
||||
using PlumbingRepairDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace PlumbingRepairDatabaseImplement.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class Message : IMessageInfoModel
|
||||
{
|
||||
[Key]
|
||||
[DataMember]
|
||||
public string MessageId { get; private set; } = string.Empty;
|
||||
[DataMember]
|
||||
public int? ClientId { get; private set; }
|
||||
[DataMember]
|
||||
public string SenderName { get; private set; } = string.Empty;
|
||||
[DataMember]
|
||||
public DateTime DateDelivery { get; private set; } = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
|
||||
[DataMember]
|
||||
public string Subject { get; private set; } = string.Empty;
|
||||
[DataMember]
|
||||
public string Body { get; private set; } = string.Empty;
|
||||
|
||||
public virtual Client? Client { get; set; }
|
||||
@ -43,5 +51,7 @@ namespace PlumbingRepairDatabaseImplement.Models
|
||||
SenderName = SenderName,
|
||||
DateDelivery = DateDelivery
|
||||
};
|
||||
|
||||
public int Id => throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
@ -3,33 +3,41 @@ using PlumbingRepairContracts.ViewModels;
|
||||
using PlumbingRepairDataModels.Enums;
|
||||
using PlumbingRepairDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace PlumbingRepairDatabaseImplement.Models
|
||||
{
|
||||
public class Order : IOrderModel
|
||||
[DataContract]
|
||||
public class Order : IOrderModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
public int WorkId { get; private set; }
|
||||
|
||||
public string WorkName { get; private set; } = string.Empty;
|
||||
[DataMember]
|
||||
public int Id { get; private set; }
|
||||
[DataMember]
|
||||
public int WorkId { get; private set; }
|
||||
[DataMember]
|
||||
public string WorkName { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public int ClientId { get; private set; }
|
||||
|
||||
[DataMember]
|
||||
public int ClientId { get; private set; }
|
||||
[DataMember]
|
||||
public int? ImplementerId { get; set; }
|
||||
[Required]
|
||||
[DataMember]
|
||||
public int Count { get; private set; }
|
||||
|
||||
[Required]
|
||||
public double Sum { get; private set; }
|
||||
[DataMember]
|
||||
public double Sum { get; private set; }
|
||||
|
||||
[Required]
|
||||
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
||||
[DataMember]
|
||||
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
||||
|
||||
[Required]
|
||||
public DateTime DateCreate { get; private set; } = DateTime.Now;
|
||||
|
||||
public DateTime? DateImplement { get; private set; }
|
||||
[DataMember]
|
||||
public DateTime DateCreate { get; private set; } = DateTime.Now;
|
||||
[DataMember]
|
||||
public DateTime? DateImplement { get; private set; }
|
||||
|
||||
public virtual Work Work { get; set; }
|
||||
public virtual Client Client { get; set; }
|
||||
|
@ -3,23 +3,29 @@ using PlumbingRepairContracts.ViewModels;
|
||||
using PlumbingRepairDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace PlumbingRepairDatabaseImplement.Models
|
||||
{
|
||||
public class Work : IWorkModel
|
||||
[DataContract]
|
||||
public class Work : IWorkModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DataMember]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public string WorkName { get; set; } = string.Empty;
|
||||
[DataMember]
|
||||
public string WorkName { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public double Price { get; set; }
|
||||
[DataMember]
|
||||
public double Price { get; set; }
|
||||
|
||||
private Dictionary<int, (IComponentModel, int)>? _workComponents = null;
|
||||
|
||||
[NotMapped]
|
||||
public Dictionary<int, (IComponentModel, int)> WorkComponents
|
||||
[DataMember]
|
||||
public Dictionary<int, (IComponentModel, int)> WorkComponents
|
||||
{
|
||||
get
|
||||
{
|
||||
|
@ -20,4 +20,8 @@
|
||||
<ProjectReference Include="..\PlumbingRepairDataModels\PlumbingRepairDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="copy /Y "$(TargetDir)*.dll" "$(SolutionDir)ImplementationExtensions\*.dll"
" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\PlumbingRepairBusinessLogic\PlumbingRepairBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\PlumbingRepairDatabaseImplement\PlumbingRepairDatabaseImplement.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
Loading…
Reference in New Issue
Block a user