как говорится, последний штрих
This commit is contained in:
parent
2b366be1b1
commit
d96fa97b7c
@ -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>();
|
||||
}
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace ConfectioneryDataModels.Models
|
||||
{
|
||||
public interface IMessageInfoModel
|
||||
public interface IMessageInfoModel : IId
|
||||
{
|
||||
string MessageId { get; }
|
||||
int? ClientId { get; }
|
||||
|
@ -8,18 +8,23 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace ConfectioneryDatabaseImplement.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class Client : IClientModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
[Required]
|
||||
[DataMember]
|
||||
public int Id { get; private set; }
|
||||
[DataMember]
|
||||
[Required]
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
[Required]
|
||||
[DataMember]
|
||||
[Required]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
[Required]
|
||||
[DataMember]
|
||||
[Required]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
|
||||
[ForeignKey("ClientId")]
|
||||
|
@ -3,15 +3,20 @@ using ConfectioneryContracts.ViewModels;
|
||||
using ConfectioneryDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace ConfectioneryDatabaseImplement.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class Component : IComponentModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
[DataMember]
|
||||
public int Id { get; private set; }
|
||||
[DataMember]
|
||||
[Required]
|
||||
public string ComponentName { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
[DataMember]
|
||||
[Required]
|
||||
public double Cost { get; set; }
|
||||
[ForeignKey("ComponentId")]
|
||||
public virtual List<PastryComponent> PastryComponents { get; set; } = new();
|
||||
|
@ -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>();
|
||||
}
|
||||
}
|
||||
}
|
@ -8,22 +8,25 @@ using ConfectioneryContracts.ViewModels;
|
||||
using ConfectioneryDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace ConfectioneryDatabaseImplement.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class Implementer : IImplementerModel
|
||||
{
|
||||
[DataMember]
|
||||
public int Id { get; set; }
|
||||
|
||||
[DataMember]
|
||||
[Required]
|
||||
public string ImplementerFIO { get; set; } = string.Empty;
|
||||
|
||||
[DataMember]
|
||||
[Required]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
|
||||
[DataMember]
|
||||
[Required]
|
||||
public int WorkExperience { get; set; }
|
||||
|
||||
[DataMember]
|
||||
[Required]
|
||||
public int Qualification { get; set; }
|
||||
|
||||
|
@ -8,28 +8,32 @@ using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace ConfectioneryDatabaseImplement.Models
|
||||
{
|
||||
public class MessageInfo : IMessageInfoModel
|
||||
{
|
||||
[NotMapped]
|
||||
public int Id { get; private set; }
|
||||
[DataMember]
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.None)]
|
||||
public string MessageId { get; set; } = string.Empty;
|
||||
|
||||
[DataMember]
|
||||
public int? ClientId { get; set; }
|
||||
|
||||
public virtual Client? Client { get; set; }
|
||||
|
||||
[DataMember]
|
||||
[Required]
|
||||
public string SenderName { get; set; } = string.Empty;
|
||||
|
||||
[DataMember]
|
||||
[Required]
|
||||
public DateTime DateDelivery { get; set; }
|
||||
|
||||
[DataMember]
|
||||
[Required]
|
||||
public string Subject { get; set; } = string.Empty;
|
||||
|
||||
[DataMember]
|
||||
[Required]
|
||||
public string Body { get; set; } = string.Empty;
|
||||
|
||||
|
@ -6,41 +6,44 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConfectioneryDatabaseImplement.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class Order : IOrderModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public int ClientId { get; private set; }
|
||||
|
||||
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();
|
||||
|
||||
[DataMember]
|
||||
public int Id { get; set; }
|
||||
[DataMember]
|
||||
[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 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)
|
||||
public static Order Create(ConfectioneryDatabase context, OrderBindingModel model)
|
||||
{
|
||||
return new Order()
|
||||
{
|
||||
|
@ -8,20 +8,26 @@ using ConfectioneryContracts.ViewModels;
|
||||
using ConfectioneryDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
|
||||
namespace ConfectioneryDatabaseImplement.Models
|
||||
{
|
||||
public class Pastry : IPastryModel
|
||||
[DataContract]
|
||||
public class Pastry : IPastryModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
[DataMember]
|
||||
public int Id { get; set; }
|
||||
[DataMember]
|
||||
[Required]
|
||||
public string PastryName { get; set; } = string.Empty;
|
||||
[Required]
|
||||
[DataMember]
|
||||
[Required]
|
||||
public double Price { get; set; }
|
||||
private Dictionary<int, (IComponentModel, int)>? _pastryComponents = null;
|
||||
[NotMapped]
|
||||
public Dictionary<int, (IComponentModel, int)> PastryComponents
|
||||
[DataMember]
|
||||
[NotMapped]
|
||||
public Dictionary<int, (IComponentModel, int)> PastryComponents
|
||||
{
|
||||
get
|
||||
{
|
||||
|
@ -4,20 +4,29 @@ using ConfectioneryDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace ConfectioneryFileImplement
|
||||
namespace ConfectioneryFileImplement.Models
|
||||
{
|
||||
public class Client : IClientModel
|
||||
[DataContract]
|
||||
public class Client : IClientModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
public string Password { get; set; } = string.Empty;
|
||||
public string Email { get; set; } = string.Empty;
|
||||
[DataMember]
|
||||
public int Id { get; private set; }
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -1,16 +1,21 @@
|
||||
using ConfectioneryContracts.BindingModels;
|
||||
using ConfectioneryContracts.ViewModels;
|
||||
using ConfectioneryDataModels.Models;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace ConfectioneryFileImplement.Models
|
||||
{
|
||||
public class Component : IComponentModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string ComponentName { get; private set; } = string.Empty;
|
||||
public double Cost { get; set; }
|
||||
public static Component? Create(ComponentBindingModel model)
|
||||
[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)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
|
@ -4,23 +4,26 @@ using ConfectioneryDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace ConfectioneryFileImplement.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class Implementer : IImplementerModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
public string ImplementerFIO { get; private set; } = string.Empty;
|
||||
|
||||
public string Password { get; private set; } = string.Empty;
|
||||
|
||||
public int WorkExperience { get; private set; }
|
||||
|
||||
public int Qualification { get; private set; }
|
||||
[DataMember]
|
||||
public int Id { get; set; }
|
||||
[DataMember]
|
||||
public string ImplementerFIO { get; set; } = string.Empty;
|
||||
[DataMember]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
[DataMember]
|
||||
public int WorkExperience { get; set; }
|
||||
[DataMember]
|
||||
public int Qualification { get; set; }
|
||||
|
||||
public static Implementer? Create(XElement element)
|
||||
{
|
||||
|
@ -4,24 +4,29 @@ using ConfectioneryDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace ConfectioneryFileImplement.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class MessageInfo : IMessageInfoModel
|
||||
{
|
||||
[DataMember]
|
||||
public int Id { get; private set; }
|
||||
[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)
|
||||
|
@ -3,22 +3,41 @@ using ConfectioneryDataModels.Models;
|
||||
using ConfectioneryContracts.BindingModels;
|
||||
using ConfectioneryContracts.ViewModels;
|
||||
using System.Xml.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace ConfectioneryFileImplement.Models
|
||||
{
|
||||
public class Order : IOrderModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public int ClientId { get; private set; }
|
||||
public int? ImplementerId { get; 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; }
|
||||
[DataContract]
|
||||
public class Order : IOrderModel
|
||||
{
|
||||
[DataMember]
|
||||
public int Id { 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)
|
||||
{
|
||||
|
@ -7,15 +7,20 @@ using ConfectioneryContracts.BindingModels;
|
||||
using ConfectioneryContracts.ViewModels;
|
||||
using ConfectioneryDataModels.Models;
|
||||
using System.Xml.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace ConfectioneryFileImplement.Models
|
||||
{
|
||||
public class Pastry : IPastryModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string PastryName { get; private set; } = string.Empty;
|
||||
public double Price { get; private set; }
|
||||
public Dictionary<int, int> Components { get; private set; } = new();
|
||||
[DataContract]
|
||||
public class Pastry : IPastryModel
|
||||
{
|
||||
[DataMember]
|
||||
public int Id { get; private set; }
|
||||
[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;
|
||||
public Dictionary<int, (IComponentModel, int)> PastryComponents
|
||||
|
@ -11,6 +11,7 @@ namespace ConfectioneryListImplement.Models
|
||||
{
|
||||
public class MessageInfo : IMessageInfoModel
|
||||
{
|
||||
public int Id => throw new NotImplementedException();
|
||||
public string MessageId { get; private set; } = string.Empty;
|
||||
|
||||
public int? ClientId { get; private set; }
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user