Compare commits

...

2 Commits

Author SHA1 Message Date
bekodeg
ffba2fd7f0 Починил отправку на почту 2024-06-23 08:29:04 +04:00
bekodeg
2dbd0a9ac8 доработки для нормальных бекапов 2024-06-18 21:09:07 +04:00
23 changed files with 178 additions and 91 deletions

View File

@ -64,7 +64,7 @@ namespace SushiBar
}); });
DependencyManager.Instance.RegisterType<IClientLogic, ClientLogic>(); DependencyManager.Instance.RegisterType<IClientLogic, ClientLogic>();
DependencyManager.Instance.RegisterType<IImplementerLogic, ImplementerLogic>(true); DependencyManager.Instance.RegisterType<IImplementerLogic, ImplementerLogic>();
DependencyManager.Instance.RegisterType<IComponentLogic, ComponentLogic>(); DependencyManager.Instance.RegisterType<IComponentLogic, ComponentLogic>();
DependencyManager.Instance.RegisterType<IOrderLogic, OrderLogic>(); DependencyManager.Instance.RegisterType<IOrderLogic, OrderLogic>();
DependencyManager.Instance.RegisterType<ISushiLogic, SushiLogic>(); DependencyManager.Instance.RegisterType<ISushiLogic, SushiLogic>();
@ -73,7 +73,7 @@ namespace SushiBar
DependencyManager.Instance.RegisterType<IMessageInfoLogic, MessageInfoLogic>(); DependencyManager.Instance.RegisterType<IMessageInfoLogic, MessageInfoLogic>();
DependencyManager.Instance.RegisterType<IBackUpLogic, BackUpLogic>(); DependencyManager.Instance.RegisterType<IBackUpLogic, BackUpLogic>();
DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>(); DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>(true);
DependencyManager.Instance.RegisterType<AbstractSaveToExcel, SaveToExcel>(); DependencyManager.Instance.RegisterType<AbstractSaveToExcel, SaveToExcel>();
DependencyManager.Instance.RegisterType<AbstractSaveToWord, SaveToWord>(); DependencyManager.Instance.RegisterType<AbstractSaveToWord, SaveToWord>();

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

@ -115,7 +115,7 @@ namespace SushiBarBusinessLogic.BusinessLogics
} }
model.Status = orderStatus; model.Status = orderStatus;
if (model.Status == OrderStatus.Выдан) if (model.Status == OrderStatus.Готов)
{ {
model.DateImplement = DateTime.Now; model.DateImplement = DateTime.Now;
} }

View File

@ -3,18 +3,24 @@ 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
{ {
public class Client : IClientModel [DataContract]
public class Client : IClientModel
{ {
public int Id { get; private set; } [DataMember]
[Required] public int Id { get; private set; }
public string ClientFIO { get; private set; } = string.Empty; [DataMember]
[Required] [Required]
public string Email { get; private set; } = string.Empty; public string ClientFIO { get; private set; } = string.Empty;
[Required] [DataMember]
public string Password { get; private set; } = string.Empty; [Required]
public string Email { get; private set; } = string.Empty;
[DataMember]
[Required]
public string Password { get; private set; } = string.Empty;
[ForeignKey("ClientId")] [ForeignKey("ClientId")]
public List<MessageInfo> Messages = new(); public List<MessageInfo> Messages = new();

View File

@ -3,16 +3,21 @@ 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
{ {
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] [Required]
public double Cost { get; set; } public string ComponentName { get; private set; } = string.Empty;
[DataMember]
[Required]
public double Cost { get; set; }
[ForeignKey("ComponentId")] [ForeignKey("ComponentId")]
public virtual List<SushiComponent> SushiComponents { get; set; } = new(); public virtual List<SushiComponent> SushiComponents { get; set; } = new();
public static Component? Create(ComponentBindingModel model) public static Component? Create(ComponentBindingModel model)

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,23 +2,26 @@
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
{ {
public class MessageInfo : IMessageInfoModel [DataContract]
public class MessageInfo : IMessageInfoModel
{ {
[Key] [DataMember]
[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,29 +3,38 @@ 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
{ {
public class Order : IOrderModel [DataContract]
public class Order : IOrderModel
{ {
public int Id { get; private set; } [DataMember]
[Required] public int Id { get; private set; }
[DataMember]
[Required]
public int Count { get; set; } public int Count { get; set; }
[Required] [DataMember]
[Required]
public double Sum { get; set; } public double Sum { get; set; }
[Required] [DataMember]
[Required]
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
[Required] [DataMember]
[Required]
public DateTime DateCreate { get; set; } = DateTime.Now; public DateTime DateCreate { get; set; } = DateTime.Now;
public DateTime? DateImplement { get; set; } [DataMember]
[Required] public DateTime? DateImplement { get; set; }
[DataMember]
[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; }
public static Order Create(SushiBarDatabase context, OrderBindingModel model) public static Order Create(SushiBarDatabase context, OrderBindingModel model)
@ -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,18 +3,24 @@ 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
{ {
public class Sushi : ISushiModel [DataContract]
public class Sushi : ISushiModel
{ {
public int Id { get; set; } [DataMember]
[Required] public int Id { get; set; }
[DataMember]
[Required]
public string SushiName { get; set; } = string.Empty; public string SushiName { get; set; } = string.Empty;
[Required] [DataMember]
[Required]
public double Price { get; set; } 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 public Dictionary<int, (IComponentModel, int)> SushiComponents
{ {
get get

View File

@ -1,18 +1,23 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
namespace SushiBarDatabaseImplement.Models namespace SushiBarDatabaseImplement.Models
{ {
public class SushiComponent [DataContract]
public class SushiComponent
{ {
public int Id { get; set; } [DataMember]
[Required] public int Id { get; set; }
[DataMember]
[Required]
public int SushiId { get; set; } public int SushiId { get; set; }
[Required] [DataMember]
[Required]
public int ComponentId { get; set; } public int ComponentId { get; set; }
[Required] [DataMember]
[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,15 +1,21 @@
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
{ {
public class Client [DataContract]
public class Client
{ {
public int Id { get; private set; } [DataMember]
public string ClientFIO { get; private set; } = string.Empty; public int Id { get; private set; }
public string Email { get; set; } = string.Empty; [DataMember]
public string Password { get; set; } = string.Empty; 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) public static Client? Create(ClientBindingModel model)
{ {
if (model == null) if (model == null)

View File

@ -1,15 +1,20 @@
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
{ {
public class Component : IComponentModel [DataContract]
public class Component : IComponentModel
{ {
public int Id { get; private set; } [DataMember]
public string ComponentName { get; private set; } = string.Empty; public int Id { get; private set; }
public double Cost { get; set; } [DataMember]
public string ComponentName { get; private set; } = string.Empty;
[DataMember]
public double Cost { get; set; }
public static Component? Create(ComponentBindingModel model) public static Component? Create(ComponentBindingModel model)
{ {
if (model == null) if (model == null)

View File

@ -1,17 +1,24 @@
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
{ {
internal class Implementer : IImplementerModel [DataContract]
internal class Implementer : IImplementerModel
{ {
public int Id { get; private set; } [DataMember]
public string ImplementerFIO { get; private set; } = string.Empty; public int Id { get; private set; }
public string Password { get; set; } = string.Empty; [DataMember]
public int Qualification { get; set; } = 0; public string ImplementerFIO { get; private set; } = string.Empty;
public int WorkExperience { get; set; } = 0; [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) public static Implementer? Create(ImplementerBindingModel model)
{ {
if (model == null) if (model == null)

View File

@ -1,23 +1,31 @@
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
{ {
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; [DataMember]
public string Subject { get; private set; } = string.Empty;
public string Body { get; private set; } = string.Empty;
[DataMember]
public string Body { get; private set; } = string.Empty;
public static MessageInfo? Create(MessageInfoBindingModel model) public static MessageInfo? Create(MessageInfoBindingModel model)
{ {

View File

@ -2,21 +2,32 @@
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
{ {
public class Order : IOrderModel [DataContract]
public class Order : IOrderModel
{ {
public int Id { get; private set; } [DataMember]
public int SushiId { get; private set; } public int Id { get; private set; }
public int ClientId { get; private set; } [DataMember]
public int? ImplementerId { get; private set; } public int SushiId { get; private set; }
public int Count { get; private set; } [DataMember]
public double Sum { get; private set; } public int ClientId { get; private set; }
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен; [DataMember]
public DateTime DateCreate { get; private set; } public int? ImplementerId { get; private set; }
public DateTime? DateImplement { 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) public static Order? Create(OrderBindingModel model)
{ {
if (model == null) if (model == null)

View File

@ -1,15 +1,20 @@
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
{ {
public class Sushi : ISushiModel [DataContract]
public class Sushi : ISushiModel
{ {
public int Id { get; private set; } [DataMember]
public string SushiName { get; private set; } = string.Empty; public int Id { get; private set; }
public double Price { 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(); public Dictionary<int, int> Components { get; private set; } = new();
private Dictionary<int, (IComponentModel, int)>? _sushiComponents = null; private Dictionary<int, (IComponentModel, int)>? _sushiComponents = null;
public Dictionary<int, (IComponentModel, int)> SushiComponents public Dictionary<int, (IComponentModel, int)> SushiComponents