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

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,16 +3,22 @@ using SushiBarContracts.ViewModels;
using SushiBarDataModels.Models;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
namespace SushiBarDatabaseImplement.Models
{
[DataContract]
public class Client : IClientModel
{
[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;

View File

@ -3,14 +3,19 @@ using SushiBarContracts.ViewModels;
using SushiBarDataModels.Models;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
namespace SushiBarDatabaseImplement.Models
{
[DataContract]
public class Component : IComponentModel
{
[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")]

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,22 +2,25 @@
using SushiBarContracts.ViewModels;
using SushiBarDataModels.Models;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
namespace SushiBarDatabaseImplement.Models
{
[DataContract]
public class MessageInfo : IMessageInfoModel
{
[DataMember]
[Key]
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.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,28 +3,37 @@ using SushiBarContracts.ViewModels;
using SushiBarDataModels.Enums;
using SushiBarDataModels.Models;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
namespace SushiBarDatabaseImplement.Models
{
[DataContract]
public class Order : IOrderModel
{
[DataMember]
public int Id { get; private set; }
[DataMember]
[Required]
public int Count { get; set; }
[DataMember]
[Required]
public double Sum { get; set; }
[DataMember]
[Required]
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
[DataMember]
[Required]
public DateTime DateCreate { get; set; } = DateTime.Now;
[DataMember]
public DateTime? DateImplement { get; set; }
[DataMember]
[Required]
public int SushiId { get; private set; }
public virtual Sushi Sushi { get; set; }
[DataMember]
public int ClientId { get; private set; }
public virtual Client Client { get; private set; }
[DataMember]
public int? ImplementerId { get; private set; }
public virtual Implementer? Implementer { get; set; }
@ -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,16 +3,22 @@ using SushiBarContracts.ViewModels;
using SushiBarDataModels.Models;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
namespace SushiBarDatabaseImplement.Models
{
[DataContract]
public class Sushi : ISushiModel
{
[DataMember]
public int Id { get; set; }
[DataMember]
[Required]
public string SushiName { get; set; } = string.Empty;
[DataMember]
[Required]
public double Price { get; set; }
private Dictionary<int, (IComponentModel, int)>? _sushiComponents = null;
[NotMapped]
public Dictionary<int, (IComponentModel, int)> SushiComponents

View File

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

View File

@ -1,14 +1,20 @@
using SushiBarContracts.BindingModels;
using SushiBarContracts.ViewModels;
using System.Runtime.Serialization;
using System.Xml.Linq;
namespace SushiBarFileImplement.Models
{
[DataContract]
public class Client
{
[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)
{

View File

@ -1,14 +1,19 @@
using SushiBarContracts.BindingModels;
using SushiBarContracts.ViewModels;
using SushiBarDataModels.Models;
using System.Runtime.Serialization;
using System.Xml.Linq;
namespace SushiBarFileImplement.Models
{
[DataContract]
public class Component : IComponentModel
{
[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)
{

View File

@ -1,16 +1,23 @@
using SushiBarContracts.BindingModels;
using SushiBarContracts.ViewModels;
using SushiBarDataModels.Models;
using System.Runtime.Serialization;
using System.Xml.Linq;
namespace SushiBarFileImplement.Models
{
[DataContract]
internal class Implementer : IImplementerModel
{
[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)
{

View File

@ -1,22 +1,30 @@
using SushiBarContracts.BindingModels;
using SushiBarContracts.ViewModels;
using SushiBarDataModels.Models;
using System.Runtime.Serialization;
using System.Xml.Linq;
namespace SushiBarFileImplement.Models
{
[DataContract]
public class MessageInfo : IMessageInfoModel
{
[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.Now;
[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,20 +2,31 @@
using SushiBarContracts.ViewModels;
using SushiBarDataModels.Enums;
using SushiBarDataModels.Models;
using System.Runtime.Serialization;
using System.Xml.Linq;
namespace SushiBarFileImplement.Models
{
[DataContract]
public class Order : IOrderModel
{
[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)
{

View File

@ -1,14 +1,19 @@
using SushiBarContracts.BindingModels;
using SushiBarContracts.ViewModels;
using SushiBarDataModels.Models;
using System.Runtime.Serialization;
using System.Xml.Linq;
namespace SushiBarFileImplement.Models
{
[DataContract]
public class Sushi : ISushiModel
{
[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;