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

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>
<ItemGroup> <ItemGroup>
<None Update="ImplementationExtensions.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="nlog.config"> <None Update="nlog.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>

View File

@ -3,16 +3,22 @@ using SushiBarContracts.ViewModels;
using SushiBarDataModels.Models; using SushiBarDataModels.Models;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
namespace SushiBarDatabaseImplement.Models namespace SushiBarDatabaseImplement.Models
{ {
[DataContract]
public class Client : IClientModel public class Client : IClientModel
{ {
[DataMember]
public int Id { get; private set; } public int Id { get; private set; }
[DataMember]
[Required] [Required]
public string ClientFIO { get; private set; } = string.Empty; public string ClientFIO { get; private set; } = string.Empty;
[DataMember]
[Required] [Required]
public string Email { get; private set; } = string.Empty; public string Email { get; private set; } = string.Empty;
[DataMember]
[Required] [Required]
public string Password { get; private set; } = string.Empty; public string Password { get; private set; } = string.Empty;

View File

@ -3,14 +3,19 @@ using SushiBarContracts.ViewModels;
using SushiBarDataModels.Models; using SushiBarDataModels.Models;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
namespace SushiBarDatabaseImplement.Models namespace SushiBarDatabaseImplement.Models
{ {
[DataContract]
public class Component : IComponentModel public class Component : IComponentModel
{ {
[DataMember]
public int Id { get; private set; } public int Id { get; private set; }
[DataMember]
[Required] [Required]
public string ComponentName { get; private set; } = string.Empty; public string ComponentName { get; private set; } = string.Empty;
[DataMember]
[Required] [Required]
public double Cost { get; set; } public double Cost { get; set; }
[ForeignKey("ComponentId")] [ForeignKey("ComponentId")]

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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