Upload files to 'ShipyardDatabaseImplement'
This commit is contained in:
parent
96b924ac1b
commit
e39c65e228
32
ShipyardDatabaseImplement/BackUpInfo.cs
Normal file
32
ShipyardDatabaseImplement/BackUpInfo.cs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
using ShipyardContracts.StorageContracts;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ShipyardDatabaseImplement
|
||||||
|
{
|
||||||
|
public class BackUpInfo : IBackUpInfo
|
||||||
|
{
|
||||||
|
public List<T>? GetList<T>() where T : class, new()
|
||||||
|
{
|
||||||
|
using var context = new ShipyardDataBase();
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -8,62 +8,69 @@ using System.ComponentModel.DataAnnotations;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace ShipyardDatabaseImplement.Models
|
namespace ShipyardDatabaseImplement.Models
|
||||||
{
|
{
|
||||||
public class Client : IClientModel
|
[DataContract]
|
||||||
{
|
public class Client : IClientModel
|
||||||
public int Id { get; private set; }
|
{
|
||||||
[Required]
|
[DataMember]
|
||||||
public string ClientFIO { get; private set; } = string.Empty;
|
public int Id { get; private set; }
|
||||||
[Required]
|
[Required]
|
||||||
public string Email { get; set; } = string.Empty;
|
[DataMember]
|
||||||
[Required]
|
public string ClientFIO { get; private set; } = string.Empty;
|
||||||
public string Password { get; set; } = string.Empty;
|
[Required]
|
||||||
[ForeignKey("ClientId")]
|
[DataMember]
|
||||||
public virtual List<Order> Orders { get; set; } = new();
|
public string Email { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
[DataMember]
|
||||||
|
public string Password { get; set; } = string.Empty;
|
||||||
[ForeignKey("ClientId")]
|
[ForeignKey("ClientId")]
|
||||||
public virtual List<MessageInfo> ClientMessages { get; set; } = new();
|
public virtual List<Order> Orders { get; set; } = new();
|
||||||
|
[ForeignKey("ClientId")]
|
||||||
|
public virtual List<MessageInfo> MessageInfos { get; set; } = new();
|
||||||
public static Client? Create(ClientBindingModel model)
|
public static Client? Create(ClientBindingModel model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new Client()
|
return new Client()
|
||||||
{
|
{
|
||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
ClientFIO = model.ClientFIO,
|
ClientFIO = model.ClientFIO,
|
||||||
Email = model.Email,
|
Email = model.Email,
|
||||||
Password = model.Password
|
Password = model.Password
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
public static Client Create(ClientViewModel model)
|
public static Client Create(ClientViewModel model)
|
||||||
{
|
{
|
||||||
return new Client()
|
return new Client()
|
||||||
{
|
{
|
||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
ClientFIO = model.ClientFIO,
|
ClientFIO = model.ClientFIO,
|
||||||
Email = model.Email,
|
Email = model.Email,
|
||||||
Password = model.Password
|
Password = model.Password
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
public void Update(ClientBindingModel model)
|
public void Update(ClientBindingModel model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ClientFIO = model.ClientFIO;
|
ClientFIO = model.ClientFIO;
|
||||||
Email = model.Email;
|
Email = model.Email;
|
||||||
Password = model.Password;
|
Password = model.Password;
|
||||||
}
|
}
|
||||||
public ClientViewModel GetViewModel => new()
|
public ClientViewModel GetViewModel => new()
|
||||||
{
|
{
|
||||||
Id = Id,
|
Id = Id,
|
||||||
ClientFIO = ClientFIO,
|
ClientFIO = ClientFIO,
|
||||||
Email = Email,
|
Email = Email,
|
||||||
Password = Password
|
Password = Password
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,16 +3,19 @@ using ShipyardContracts.ViewModels;
|
|||||||
using ShipyardDataModels.Models;
|
using ShipyardDataModels.Models;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace ShipyardDatabaseImplement.Models
|
namespace ShipyardDatabaseImplement.Models
|
||||||
{
|
{
|
||||||
public class Component : IComponentModel
|
[DataContract]
|
||||||
|
public class Component : IComponentModel
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
[DataMember]
|
||||||
[Required]
|
public int Id { get; private set; }
|
||||||
public string ComponentName { get; private set; } = string.Empty;
|
[DataMember]
|
||||||
[Required]
|
public string ComponentName { get; private set; } = string.Empty;
|
||||||
public double Cost { get; set; }
|
[DataMember]
|
||||||
|
public double Cost { get; set; }
|
||||||
[ForeignKey("ComponentId")]
|
[ForeignKey("ComponentId")]
|
||||||
public virtual List<ShipComponent> ShipComponents { get; set; } =
|
public virtual List<ShipComponent> ShipComponents { get; set; } =
|
||||||
new();
|
new();
|
||||||
|
33
ShipyardDatabaseImplement/DatabaseImplementationExtension.cs
Normal file
33
ShipyardDatabaseImplement/DatabaseImplementationExtension.cs
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
using ShipyardContracts.DI;
|
||||||
|
using ShipyardContracts.StorageContracts;
|
||||||
|
using ShipyardContracts.StoragesContracts;
|
||||||
|
using ShipyardDatabaseImplement.Implements;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ShipyardDatabaseImplement
|
||||||
|
{
|
||||||
|
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<IShipStorage,
|
||||||
|
ShipStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -21,4 +21,8 @@
|
|||||||
<ProjectReference Include="..\..\ShipyardBusinessLogic\ShipyardBusinessLogic\ShipyardBusinessLogic.csproj" />
|
<ProjectReference Include="..\..\ShipyardBusinessLogic\ShipyardBusinessLogic\ShipyardBusinessLogic.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||||
|
<Exec Command="copy /Y "$(TargetDir)*.dll" "$(SolutionDir)ImplementationExtensions\*.dll"" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user