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

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,17 +8,22 @@ 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
{ {
[DataMember]
public int Id { get; private set; } public int Id { get; private set; }
[DataMember]
[Required] [Required]
public string ClientFIO { get; set; } = string.Empty; public string ClientFIO { get; set; } = string.Empty;
[DataMember]
[Required] [Required]
public string Email { get; set; } = string.Empty; public string Email { get; set; } = string.Empty;
[DataMember]
[Required] [Required]
public string Password { get; set; } = string.Empty; public string Password { get; set; } = string.Empty;

View File

@ -3,14 +3,19 @@ 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
{ {
[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

@ -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,39 +6,42 @@ 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]
public int Id { get; set; }
[DataMember]
[Required] [Required]
public int ClientId { get; private set; } public int PastryId { get; set; }
[DataMember]
public virtual Client Client { get; private set; } = new();
[Required] [Required]
public int PastryId { get; private set; } public int ClientId { get; set; }
[DataMember]
public virtual Pastry Pastry { get; set; } = new();
public int? ImplementerId { get; private set; } public int? ImplementerId { get; private set; }
public virtual Implementer? Implementer { get; set; } = new(); [DataMember]
[Required] [Required]
public int Count { get; private set; } public int Count { get; set; }
[DataMember]
[Required] [Required]
public double Sum { get; private set; } public double Sum { get; set; }
[DataMember]
[Required] [Required]
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен; public OrderStatus Status { get; set; }
[DataMember]
[Required] [Required]
public DateTime DateCreate { get; private set; } = DateTime.Now; public DateTime DateCreate { get; set; }
[DataMember]
public DateTime? DateImplement { get; private set; } public DateTime? DateImplement { get; set; }
public virtual Pastry Pastry { get; set; }
public virtual Client Client { get; set; }
public virtual Implementer? Implementer { get; set; }
public static Order Create(ConfectioneryDatabase context, OrderBindingModel model) public static Order Create(ConfectioneryDatabase context, OrderBindingModel model)
{ {

View File

@ -8,18 +8,24 @@ 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 Pastry : IPastryModel public class Pastry : IPastryModel
{ {
[DataMember]
public int Id { get; set; } public int Id { get; set; }
[DataMember]
[Required] [Required]
public string PastryName { get; set; } = string.Empty; public string PastryName { get; set; } = string.Empty;
[DataMember]
[Required] [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;
[DataMember]
[NotMapped] [NotMapped]
public Dictionary<int, (IComponentModel, int)> PastryComponents public Dictionary<int, (IComponentModel, int)> PastryComponents
{ {

View File

@ -4,18 +4,27 @@ 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
{ {
[DataContract]
public class Client : IClientModel 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; [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) public static Client? Create(ClientBindingModel? model)
{ {

View File

@ -1,14 +1,19 @@
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
{ {
[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

@ -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,19 +3,38 @@ 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
{ {
[DataContract]
public class Order : IOrderModel public class Order : IOrderModel
{ {
[DataMember]
public int Id { get; private set; } public int Id { get; private set; }
public int ClientId { get; private set; }
public int? ImplementerId { get; set; } [DataMember]
public int PastryId { get; private set; } 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; } public int Count { get; private set; }
[DataMember]
public double Sum { get; private set; } public double Sum { get; private set; }
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
public DateTime DateCreate { get; private set; } = DateTime.Now; [DataMember]
public OrderStatus Status { get; private set; }
[DataMember]
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

@ -7,13 +7,18 @@ 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
{ {
[DataContract]
public class Pastry : IPastryModel public class Pastry : IPastryModel
{ {
[DataMember]
public int Id { get; private set; } public int Id { get; private set; }
[DataMember]
public string PastryName { get; private set; } = string.Empty; public string PastryName { 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();

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; }