как говорится, последний штрих

This commit is contained in:
malimova 2024-06-03 01:01:18 +04:00
parent 2b366be1b1
commit d96fa97b7c
21 changed files with 237 additions and 95 deletions

View File

@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Unity.Microsoft.Logging;
using Unity;
using Microsoft.Extensions.Logging;
namespace ConfectioneryContracts.DI
{
public class UnityDependencyContainer : IDependencyContainer
{
private readonly IUnityContainer _container;
public UnityDependencyContainer()
{
_container = new UnityContainer();
}
public void AddLogging(Action<ILoggingBuilder> configure)
{
var factory = LoggerFactory.Create(configure);
_container.AddExtension(new LoggingExtension(factory));
}
public void RegisterType<T, U>(bool isSingle) where U : class, T where T : class
{
_container.RegisterType<T, U>(isSingle ? TypeLifetime.Singleton : TypeLifetime.Transient);
}
public void RegisterType<T>(bool isSingle) where T : class
{
_container.RegisterType<T>(isSingle ? TypeLifetime.Singleton : TypeLifetime.Transient);
}
public T Resolve<T>()
{
return _container.Resolve<T>();
}
}
}

View File

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace ConfectioneryDataModels.Models namespace ConfectioneryDataModels.Models
{ {
public interface IMessageInfoModel public interface IMessageInfoModel : IId
{ {
string MessageId { get; } string MessageId { get; }
int? ClientId { get; } int? ClientId { get; }

View File

@ -8,18 +8,23 @@ using System.Collections.Generic;
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 ConfectioneryDatabaseImplement.Models namespace ConfectioneryDatabaseImplement.Models
{ {
[DataContract]
public class Client : IClientModel public class Client : IClientModel
{ {
public int Id { get; private set; } [DataMember]
public int Id { get; private set; }
[Required] [DataMember]
[Required]
public string ClientFIO { get; set; } = string.Empty; public string ClientFIO { get; set; } = string.Empty;
[Required] [DataMember]
[Required]
public string Email { get; set; } = string.Empty; public string Email { get; set; } = string.Empty;
[Required] [DataMember]
[Required]
public string Password { get; set; } = string.Empty; public string Password { get; set; } = string.Empty;
[ForeignKey("ClientId")] [ForeignKey("ClientId")]

View File

@ -3,15 +3,20 @@ using ConfectioneryContracts.ViewModels;
using ConfectioneryDataModels.Models; using ConfectioneryDataModels.Models;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
namespace ConfectioneryDatabaseImplement.Models namespace ConfectioneryDatabaseImplement.Models
{ {
[DataContract]
public class Component : IComponentModel public class Component : IComponentModel
{ {
public int Id { get; private set; } [DataMember]
[Required] public int Id { get; private set; }
[DataMember]
[Required]
public string ComponentName { get; private set; } = string.Empty; public string ComponentName { get; private set; } = string.Empty;
[Required] [DataMember]
[Required]
public double Cost { get; set; } public double Cost { get; set; }
[ForeignKey("ComponentId")] [ForeignKey("ComponentId")]
public virtual List<PastryComponent> PastryComponents { get; set; } = new(); public virtual List<PastryComponent> PastryComponents { get; set; } = new();

View File

@ -0,0 +1,27 @@
using ConfectioneryContracts.DI;
using ConfectioneryContracts.StoragesContracts;
using ConfectioneryDatabaseImplement.Implements;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConfectioneryDatabaseImplement
{
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<IPastryStorage, PastryStorage>();
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
}
}
}

View File

@ -8,22 +8,25 @@ using ConfectioneryContracts.ViewModels;
using ConfectioneryDataModels.Models; using ConfectioneryDataModels.Models;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
namespace ConfectioneryDatabaseImplement.Models namespace ConfectioneryDatabaseImplement.Models
{ {
[DataContract]
public class Implementer : IImplementerModel public class Implementer : IImplementerModel
{ {
[DataMember]
public int Id { get; set; } public int Id { get; set; }
[DataMember]
[Required] [Required]
public string ImplementerFIO { get; set; } = string.Empty; public string ImplementerFIO { get; 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 WorkExperience { get; set; } public int WorkExperience { get; set; }
[DataMember]
[Required] [Required]
public int Qualification { get; set; } public int Qualification { get; set; }

View File

@ -8,28 +8,32 @@ 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 ConfectioneryDatabaseImplement.Models namespace ConfectioneryDatabaseImplement.Models
{ {
public class MessageInfo : IMessageInfoModel public class MessageInfo : IMessageInfoModel
{ {
[NotMapped]
public int Id { get; private set; }
[DataMember]
[Key] [Key]
[DatabaseGenerated(DatabaseGeneratedOption.None)] [DatabaseGenerated(DatabaseGeneratedOption.None)]
public string MessageId { get; set; } = string.Empty; public string MessageId { get; set; } = string.Empty;
[DataMember]
public int? ClientId { get; set; } public int? ClientId { get; set; }
public virtual Client? Client { get; set; } public virtual Client? Client { get; set; }
[DataMember]
[Required] [Required]
public string SenderName { get; set; } = string.Empty; public string SenderName { get; set; } = string.Empty;
[DataMember]
[Required] [Required]
public DateTime DateDelivery { get; set; } public DateTime DateDelivery { get; set; }
[DataMember]
[Required] [Required]
public string Subject { get; set; } = string.Empty; public string Subject { get; set; } = string.Empty;
[DataMember]
[Required] [Required]
public string Body { get; set; } = string.Empty; public string Body { get; set; } = string.Empty;

View File

@ -6,41 +6,44 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Linq; using System.Linq;
using System.Runtime.Serialization;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace ConfectioneryDatabaseImplement.Models namespace ConfectioneryDatabaseImplement.Models
{ {
[DataContract]
public class Order : IOrderModel public class Order : IOrderModel
{ {
public int Id { get; private set; } [DataMember]
[Required] public int Id { get; set; }
public int ClientId { get; private set; } [DataMember]
public virtual Client Client { get; private set; } = new();
[Required]
public int PastryId { get; private set; }
public virtual Pastry Pastry { get; set; } = new();
public int? ImplementerId { get; private set; }
public virtual Implementer? Implementer { get; set; } = new();
[Required] [Required]
public int Count { get; private set; } public int PastryId { get; set; }
[DataMember]
[Required]
public int ClientId { get; set; }
[DataMember]
public int? ImplementerId { get; private set; }
[DataMember]
[Required]
public int Count { get; set; }
[DataMember]
[Required]
public double Sum { get; set; }
[DataMember]
[Required]
public OrderStatus Status { get; set; }
[DataMember]
[Required]
public DateTime DateCreate { get; set; }
[DataMember]
public DateTime? DateImplement { get; set; }
public virtual Pastry Pastry { get; set; }
public virtual Client Client { get; set; }
public virtual Implementer? Implementer { get; set; }
[Required] public static Order Create(ConfectioneryDatabase context, OrderBindingModel model)
public double Sum { get; private set; }
[Required]
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
[Required]
public DateTime DateCreate { get; private set; } = DateTime.Now;
public DateTime? DateImplement { get; private set; }
public static Order Create(ConfectioneryDatabase context, OrderBindingModel model)
{ {
return new Order() return new Order()
{ {

View File

@ -8,20 +8,26 @@ using ConfectioneryContracts.ViewModels;
using ConfectioneryDataModels.Models; using ConfectioneryDataModels.Models;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
namespace ConfectioneryDatabaseImplement.Models namespace ConfectioneryDatabaseImplement.Models
{ {
public class Pastry : IPastryModel [DataContract]
public class Pastry : IPastryModel
{ {
public int Id { get; set; } [DataMember]
[Required] public int Id { get; set; }
[DataMember]
[Required]
public string PastryName { get; set; } = string.Empty; public string PastryName { get; set; } = string.Empty;
[Required] [DataMember]
[Required]
public double Price { get; set; } public double Price { get; set; }
private Dictionary<int, (IComponentModel, int)>? _pastryComponents = null; private Dictionary<int, (IComponentModel, int)>? _pastryComponents = null;
[NotMapped] [DataMember]
public Dictionary<int, (IComponentModel, int)> PastryComponents [NotMapped]
public Dictionary<int, (IComponentModel, int)> PastryComponents
{ {
get get
{ {

View File

@ -4,20 +4,29 @@ using ConfectioneryDataModels.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Runtime.Serialization;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Xml.Linq; using System.Xml.Linq;
namespace ConfectioneryFileImplement namespace ConfectioneryFileImplement.Models
{ {
public class Client : IClientModel [DataContract]
public class Client : IClientModel
{ {
public int Id { get; set; } [DataMember]
public string ClientFIO { get; set; } = string.Empty; public int Id { get; private set; }
public string Password { get; set; } = string.Empty;
public string Email { get; set; } = string.Empty;
public static Client? Create(ClientBindingModel? model) [DataMember]
public string ClientFIO { get; private set; } = string.Empty;
[DataMember]
public string Email { get; private set; } = string.Empty;
[DataMember]
public string Password { get; private set; } = string.Empty;
public static Client? Create(ClientBindingModel? model)
{ {
if (model == null) if (model == null)
{ {

View File

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

View File

@ -4,23 +4,26 @@ using ConfectioneryDataModels.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Runtime.Serialization;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Xml.Linq; using System.Xml.Linq;
namespace ConfectioneryFileImplement.Models namespace ConfectioneryFileImplement.Models
{ {
[DataContract]
public class Implementer : IImplementerModel public class Implementer : IImplementerModel
{ {
public int Id { get; private set; } [DataMember]
public int Id { get; set; }
public string ImplementerFIO { get; private set; } = string.Empty; [DataMember]
public string ImplementerFIO { get; set; } = string.Empty;
public string Password { get; private set; } = string.Empty; [DataMember]
public string Password { get; set; } = string.Empty;
public int WorkExperience { get; private set; } [DataMember]
public int WorkExperience { get; set; }
public int Qualification { get; private set; } [DataMember]
public int Qualification { get; set; }
public static Implementer? Create(XElement element) public static Implementer? Create(XElement element)
{ {

View File

@ -4,24 +4,29 @@ using ConfectioneryDataModels.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Runtime.Serialization;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Xml.Linq; using System.Xml.Linq;
namespace ConfectioneryFileImplement.Models namespace ConfectioneryFileImplement.Models
{ {
[DataContract]
public class MessageInfo : IMessageInfoModel public class MessageInfo : IMessageInfoModel
{ {
[DataMember]
public int Id { get; private set; }
[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

@ -3,22 +3,41 @@ using ConfectioneryDataModels.Models;
using ConfectioneryContracts.BindingModels; using ConfectioneryContracts.BindingModels;
using ConfectioneryContracts.ViewModels; using ConfectioneryContracts.ViewModels;
using System.Xml.Linq; using System.Xml.Linq;
using System.Runtime.Serialization;
namespace ConfectioneryFileImplement.Models namespace ConfectioneryFileImplement.Models
{ {
public class Order : IOrderModel [DataContract]
{ public class Order : IOrderModel
public int Id { get; private set; } {
public int ClientId { get; private set; } [DataMember]
public int? ImplementerId { get; set; } public int Id { get; private set; }
public int PastryId { 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; } = DateTime.Now;
public DateTime? DateImplement { get; private set; }
public static Order? Create(OrderBindingModel? model) [DataMember]
public int PastryId { 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; }
[DataMember]
public DateTime DateCreate { get; private set; }
[DataMember]
public DateTime? DateImplement { get; private set; }
public static Order? Create(OrderBindingModel? model)
{ {
if (model == null) if (model == null)
{ {

View File

@ -7,15 +7,20 @@ using ConfectioneryContracts.BindingModels;
using ConfectioneryContracts.ViewModels; using ConfectioneryContracts.ViewModels;
using ConfectioneryDataModels.Models; using ConfectioneryDataModels.Models;
using System.Xml.Linq; using System.Xml.Linq;
using System.Runtime.Serialization;
namespace ConfectioneryFileImplement.Models namespace ConfectioneryFileImplement.Models
{ {
public class Pastry : IPastryModel [DataContract]
{ public class Pastry : IPastryModel
public int Id { get; private set; } {
public string PastryName { get; private set; } = string.Empty; [DataMember]
public double Price { get; private set; } public int Id { get; private set; }
public Dictionary<int, int> Components { get; private set; } = new(); [DataMember]
public string PastryName { 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)>? _pastryComponents = null; private Dictionary<int, (IComponentModel, int)>? _pastryComponents = null;
public Dictionary<int, (IComponentModel, int)> PastryComponents public Dictionary<int, (IComponentModel, int)> PastryComponents

View File

@ -11,6 +11,7 @@ namespace ConfectioneryListImplement.Models
{ {
public class MessageInfo : IMessageInfoModel public class MessageInfo : IMessageInfoModel
{ {
public int Id => throw new NotImplementedException();
public string MessageId { get; private set; } = string.Empty; public string MessageId { get; private set; } = string.Empty;
public int? ClientId { get; private set; } public int? ClientId { get; private set; }