доработки для нормальных бекапов

This commit is contained in:
bekodeg 2024-06-18 21:09:07 +04:00
parent a2737c5f00
commit 2dbd0a9ac8
21 changed files with 175 additions and 88 deletions

View File

@ -27,6 +27,9 @@
</ItemGroup>
<ItemGroup>
<None Update="ImplementationExtensions.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="nlog.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>

View File

@ -3,18 +3,24 @@ using SushiBarContracts.ViewModels;
using SushiBarDataModels.Models;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
namespace SushiBarDatabaseImplement.Models
{
public class Client : IClientModel
[DataContract]
public class Client : IClientModel
{
public int Id { get; private set; }
[Required]
public string ClientFIO { get; private set; } = string.Empty;
[Required]
public string Email { get; private set; } = string.Empty;
[Required]
public string Password { get; private set; } = string.Empty;
[DataMember]
public int Id { get; private set; }
[DataMember]
[Required]
public string ClientFIO { get; private set; } = string.Empty;
[DataMember]
[Required]
public string Email { get; private set; } = string.Empty;
[DataMember]
[Required]
public string Password { get; private set; } = string.Empty;
[ForeignKey("ClientId")]
public List<MessageInfo> Messages = new();

View File

@ -3,16 +3,21 @@ using SushiBarContracts.ViewModels;
using SushiBarDataModels.Models;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
namespace SushiBarDatabaseImplement.Models
{
public class Component : IComponentModel
[DataContract]
public class Component : IComponentModel
{
public int Id { get; private set; }
[Required]
public string ComponentName { get; private set; } = string.Empty;
[Required]
public double Cost { get; set; }
[DataMember]
public int Id { get; private set; }
[DataMember]
[Required]
public string ComponentName { get; private set; } = string.Empty;
[DataMember]
[Required]
public double Cost { get; set; }
[ForeignKey("ComponentId")]
public virtual List<SushiComponent> SushiComponents { get; set; } = new();
public static Component? Create(ComponentBindingModel model)

View File

@ -3,18 +3,25 @@ using System.ComponentModel.DataAnnotations;
using SushiBarDataModels.Models;
using SushiBarContracts.BindingModels;
using SushiBarContracts.ViewModels;
using System.Runtime.Serialization;
namespace SushiBarDatabaseImplement.Models
{
[DataContract]
public class Implementer : IImplementerModel
{
[DataMember]
public int Id { get; private set; }
[DataMember]
[Required]
public string ImplementerFIO { get; private set; } = string.Empty;
[DataMember]
[Required]
public string Password { get; set; } = string.Empty;
[DataMember]
[Required]
public int Qualification { get; set; } = 0;
[DataMember]
[Required]
public int WorkExperience { get; set; } = 0;
[ForeignKey("ImplementerId")]

View File

@ -2,23 +2,26 @@
using SushiBarContracts.ViewModels;
using SushiBarDataModels.Models;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
namespace SushiBarDatabaseImplement.Models
{
public class MessageInfo : IMessageInfoModel
[DataContract]
public class MessageInfo : IMessageInfoModel
{
[Key]
[DataMember]
[Key]
public string MessageId { get; private set; } = string.Empty;
public int? ClientId { get; private set; }
public string SenderName { get; private set; } = string.Empty;
public DateTime DateDelivery { get; private set; } = DateTime.Now;
public string Subject { get; private set; } = string.Empty;
public string Body { 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.Now;
[DataMember]
public string Subject { get; private set; } = string.Empty;
[DataMember]
public string Body { get; private set; } = string.Empty;
public Client? Client;
public static MessageInfo? Create(SushiBarDatabase context, MessageInfoBindingModel model)
{

View File

@ -3,29 +3,38 @@ using SushiBarContracts.ViewModels;
using SushiBarDataModels.Enums;
using SushiBarDataModels.Models;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
namespace SushiBarDatabaseImplement.Models
{
public class Order : IOrderModel
[DataContract]
public class Order : IOrderModel
{
public int Id { get; private set; }
[Required]
[DataMember]
public int Id { get; private set; }
[DataMember]
[Required]
public int Count { get; set; }
[Required]
[DataMember]
[Required]
public double Sum { get; set; }
[Required]
[DataMember]
[Required]
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
[Required]
[DataMember]
[Required]
public DateTime DateCreate { get; set; } = DateTime.Now;
public DateTime? DateImplement { get; set; }
[Required]
[DataMember]
public DateTime? DateImplement { get; set; }
[DataMember]
[Required]
public int SushiId { get; private set; }
public virtual Sushi Sushi { get; set; }
public int ClientId { get; private set; }
[DataMember]
public int ClientId { get; private set; }
public virtual Client Client { get; private set; }
public int? ImplementerId { get; private set; }
[DataMember]
public int? ImplementerId { get; private set; }
public virtual Implementer? Implementer { get; set; }
public static Order Create(SushiBarDatabase context, OrderBindingModel model)
@ -46,6 +55,7 @@ namespace SushiBarDatabaseImplement.Models
Sushi = context.Sushis.First(x => x.Id == model.SushiId),
ClientId = model.ClientId,
Client = context.Clients.First(x => x.Id == model.ClientId),
ImplementerId = model.ImplementerId,
Implementer = model.ImplementerId == null ? null : context.Implementers.First(i => i.Id == model.ImplementerId)
};
}

View File

@ -3,18 +3,24 @@ using SushiBarContracts.ViewModels;
using SushiBarDataModels.Models;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
namespace SushiBarDatabaseImplement.Models
{
public class Sushi : ISushiModel
[DataContract]
public class Sushi : ISushiModel
{
public int Id { get; set; }
[Required]
[DataMember]
public int Id { get; set; }
[DataMember]
[Required]
public string SushiName { get; set; } = string.Empty;
[Required]
[DataMember]
[Required]
public double Price { get; set; }
private Dictionary<int, (IComponentModel, int)>? _sushiComponents = null;
[NotMapped]
private Dictionary<int, (IComponentModel, int)>? _sushiComponents = null;
[NotMapped]
public Dictionary<int, (IComponentModel, int)> SushiComponents
{
get

View File

@ -1,18 +1,23 @@
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
namespace SushiBarDatabaseImplement.Models
{
public class SushiComponent
[DataContract]
public class SushiComponent
{
public int Id { get; set; }
[Required]
[DataMember]
public int Id { get; set; }
[DataMember]
[Required]
public int SushiId { get; set; }
[Required]
[DataMember]
[Required]
public int ComponentId { get; set; }
[Required]
[DataMember]
[Required]
public int Count { get; set; }
public virtual Component Component { get; set; } = new();
public virtual Component Component { get; set; } = new();
public virtual Sushi Sushi { get; set; } = new();
}
}

View File

@ -1,15 +1,21 @@
using SushiBarContracts.BindingModels;
using SushiBarContracts.ViewModels;
using System.Runtime.Serialization;
using System.Xml.Linq;
namespace SushiBarFileImplement.Models
{
public class Client
[DataContract]
public class Client
{
public int Id { get; private set; }
public string ClientFIO { get; private set; } = string.Empty;
public string Email { get; set; } = string.Empty;
public string Password { get; set; } = string.Empty;
[DataMember]
public int Id { get; private set; }
[DataMember]
public string ClientFIO { get; private set; } = string.Empty;
[DataMember]
public string Email { get; set; } = string.Empty;
[DataMember]
public string Password { get; set; } = string.Empty;
public static Client? Create(ClientBindingModel model)
{
if (model == null)

View File

@ -1,15 +1,20 @@
using SushiBarContracts.BindingModels;
using SushiBarContracts.ViewModels;
using SushiBarDataModels.Models;
using System.Runtime.Serialization;
using System.Xml.Linq;
namespace SushiBarFileImplement.Models
{
public class Component : IComponentModel
[DataContract]
public class Component : IComponentModel
{
public int Id { get; private set; }
public string ComponentName { get; private set; } = string.Empty;
public double Cost { get; set; }
[DataMember]
public int Id { get; private set; }
[DataMember]
public string ComponentName { get; private set; } = string.Empty;
[DataMember]
public double Cost { get; set; }
public static Component? Create(ComponentBindingModel model)
{
if (model == null)

View File

@ -1,17 +1,24 @@
using SushiBarContracts.BindingModels;
using SushiBarContracts.ViewModels;
using SushiBarDataModels.Models;
using System.Runtime.Serialization;
using System.Xml.Linq;
namespace SushiBarFileImplement.Models
{
internal class Implementer : IImplementerModel
[DataContract]
internal class Implementer : IImplementerModel
{
public int Id { get; private set; }
public string ImplementerFIO { get; private set; } = string.Empty;
public string Password { get; set; } = string.Empty;
public int Qualification { get; set; } = 0;
public int WorkExperience { get; set; } = 0;
[DataMember]
public int Id { get; private set; }
[DataMember]
public string ImplementerFIO { get; private set; } = string.Empty;
[DataMember]
public string Password { get; set; } = string.Empty;
[DataMember]
public int Qualification { get; set; } = 0;
[DataMember]
public int WorkExperience { get; set; } = 0;
public static Implementer? Create(ImplementerBindingModel model)
{
if (model == null)

View File

@ -1,23 +1,31 @@
using SushiBarContracts.BindingModels;
using SushiBarContracts.ViewModels;
using SushiBarDataModels.Models;
using System.Runtime.Serialization;
using System.Xml.Linq;
namespace SushiBarFileImplement.Models
{
public class MessageInfo : IMessageInfoModel
[DataContract]
public class MessageInfo : IMessageInfoModel
{
public string MessageId { get; private set; } = string.Empty;
[DataMember]
public string MessageId { get; private set; } = string.Empty;
public int? ClientId { get; private set; }
[DataMember]
public int? ClientId { get; private set; }
public string SenderName { get; private set; } = string.Empty;
[DataMember]
public string SenderName { get; private set; } = string.Empty;
public DateTime DateDelivery { get; private set; } = DateTime.Now;
[DataMember]
public DateTime DateDelivery { get; private set; } = DateTime.Now;
public string Subject { get; private set; } = string.Empty;
public string Body { get; private set; } = string.Empty;
[DataMember]
public string Subject { get; private set; } = string.Empty;
[DataMember]
public string Body { get; private set; } = string.Empty;
public static MessageInfo? Create(MessageInfoBindingModel model)
{

View File

@ -2,21 +2,32 @@
using SushiBarContracts.ViewModels;
using SushiBarDataModels.Enums;
using SushiBarDataModels.Models;
using System.Runtime.Serialization;
using System.Xml.Linq;
namespace SushiBarFileImplement.Models
{
public class Order : IOrderModel
[DataContract]
public class Order : IOrderModel
{
public int Id { get; private set; }
public int SushiId { get; private set; }
public int ClientId { get; private set; }
public int? ImplementerId { get; private set; }
public int Count { get; private set; }
public double Sum { get; private set; }
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
public DateTime DateCreate { get; private set; }
public DateTime? DateImplement { get; private set; }
[DataMember]
public int Id { get; private set; }
[DataMember]
public int SushiId { get; private set; }
[DataMember]
public int ClientId { get; private set; }
[DataMember]
public int? ImplementerId { get; private set; }
[DataMember]
public int Count { get; private set; }
[DataMember]
public double Sum { get; private set; }
[DataMember]
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
[DataMember]
public DateTime DateCreate { get; private set; }
[DataMember]
public DateTime? DateImplement { get; private set; }
public static Order? Create(OrderBindingModel model)
{
if (model == null)

View File

@ -1,15 +1,20 @@
using SushiBarContracts.BindingModels;
using SushiBarContracts.ViewModels;
using SushiBarDataModels.Models;
using System.Runtime.Serialization;
using System.Xml.Linq;
namespace SushiBarFileImplement.Models
{
public class Sushi : ISushiModel
[DataContract]
public class Sushi : ISushiModel
{
public int Id { get; private set; }
public string SushiName { get; private set; } = string.Empty;
public double Price { get; private set; }
[DataMember]
public int Id { get; private set; }
[DataMember]
public string SushiName { get; private set; } = string.Empty;
[DataMember]
public double Price { get; private set; }
public Dictionary<int, int> Components { get; private set; } = new();
private Dictionary<int, (IComponentModel, int)>? _sushiComponents = null;
public Dictionary<int, (IComponentModel, int)> SushiComponents