добавлены DataContract и DataMember
This commit is contained in:
parent
5eea91c76d
commit
5b8087029b
@ -0,0 +1,22 @@
|
||||
using IceCreamShopContracts.DI;
|
||||
using IceCreamShopContracts.StoragesContracts;
|
||||
using IceCreamShopDatabaseImplement.Implements;
|
||||
|
||||
namespace IceCreamShopDatabaseImplement
|
||||
{
|
||||
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<IIceCreamStorage, IceCreamStorage>();
|
||||
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
||||
}
|
||||
}
|
||||
}
|
@ -3,20 +3,26 @@ using IceCreamShopContracts.ViewModels;
|
||||
using AbstractIceCreamShopDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace IceCreamShopDatabaseImplement.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class Client : IClientModel
|
||||
{
|
||||
[Required]
|
||||
[DataMember]
|
||||
public string ClientFIO { get; private set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
[DataMember]
|
||||
public string Email { get; private set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
[DataMember]
|
||||
public string Password { get; private set; } = string.Empty;
|
||||
|
||||
[DataMember]
|
||||
public int Id { get; private set; }
|
||||
|
||||
[ForeignKey("ClientId")]
|
||||
|
@ -3,18 +3,22 @@ using System.ComponentModel.DataAnnotations;
|
||||
using IceCreamShopContracts.BindingModels;
|
||||
using IceCreamShopContracts.ViewModels;
|
||||
using AbstractIceCreamShopDataModels.Models;
|
||||
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace IceCreamShopDatabaseImplement.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class Component : IComponentModel
|
||||
{
|
||||
[DataMember]
|
||||
public int Id { get; private set; }
|
||||
|
||||
[Required]
|
||||
[DataMember]
|
||||
public string ComponentName { get; private set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
[DataMember]
|
||||
public double Cost { get; set; }
|
||||
|
||||
[ForeignKey("ComponentId")]
|
||||
|
@ -3,22 +3,28 @@ using IceCreamShopContracts.BindingModels;
|
||||
using IceCreamShopContracts.ViewModels;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace IceCreamShopDatabaseImplement.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class IceCream : IIceCreamModel
|
||||
{
|
||||
[DataMember]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[DataMember]
|
||||
public string IceCreamName { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
[DataMember]
|
||||
public double Price { get; set; }
|
||||
|
||||
private Dictionary<int, (IComponentModel, int)>? _iceCreamComponents = null;
|
||||
|
||||
[NotMapped]
|
||||
[DataMember]
|
||||
public Dictionary<int, (IComponentModel, int)> IceCreamComponents
|
||||
{
|
||||
get
|
||||
|
@ -2,19 +2,26 @@
|
||||
using IceCreamShopContracts.BindingModels;
|
||||
using IceCreamShopContracts.ViewModels;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace IceCreamShopDatabaseImplement.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class Implementer : IImplementerModel
|
||||
{
|
||||
[DataMember]
|
||||
public int Id { get; private set; }
|
||||
|
||||
[DataMember]
|
||||
public string ImplementerFIO { get; private set; } = string.Empty;
|
||||
|
||||
[DataMember]
|
||||
public string Password { get; private set; } = string.Empty;
|
||||
|
||||
[DataMember]
|
||||
public int WorkExperience { get; private set; }
|
||||
|
||||
[DataMember]
|
||||
public int Qualification { get; private set; }
|
||||
|
||||
[ForeignKey("ImplementerId")]
|
||||
|
@ -2,12 +2,15 @@
|
||||
using IceCreamShopContracts.BindingModels;
|
||||
using IceCreamShopContracts.ViewModels;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace IceCreamShopDatabaseImplement.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class MessageInfo : IMessageInfoModel
|
||||
{
|
||||
[Key]
|
||||
[DataMember]
|
||||
public string MessageId { get; private set; } = string.Empty;
|
||||
|
||||
public int? ClientId { get; private set; }
|
||||
|
@ -4,27 +4,44 @@ using IceCreamShopContracts.BindingModels;
|
||||
using IceCreamShopContracts.ViewModels;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Reflection.Metadata;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace IceCreamShopDatabaseImplement.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class Order : IOrderModel
|
||||
{
|
||||
[Required]
|
||||
public int IceCreamId { get; set; }
|
||||
[DataMember]
|
||||
public int IceCreamId { get; private set; }
|
||||
|
||||
[Required]
|
||||
[DataMember]
|
||||
public int ClientId { get; private set; }
|
||||
|
||||
[DataMember]
|
||||
public int? ImplementerId { get; private set; }
|
||||
[Required]
|
||||
public int Count { get; set; }
|
||||
[Required]
|
||||
public double Sum { get; set; }
|
||||
[Required]
|
||||
public OrderStatus Status { get; set; }
|
||||
[Required]
|
||||
public DateTime DateCreate { get; set; }
|
||||
|
||||
public DateTime? DateImplement { get; set; }
|
||||
[Required]
|
||||
[DataMember]
|
||||
public int Count { get; private set; }
|
||||
|
||||
[Required]
|
||||
[DataMember]
|
||||
public double Sum { get; private set; }
|
||||
|
||||
[Required]
|
||||
[DataMember]
|
||||
public OrderStatus Status { get; private set; }
|
||||
|
||||
[Required]
|
||||
[DataMember]
|
||||
public DateTime DateCreate { get; private set; }
|
||||
|
||||
[DataMember]
|
||||
public DateTime? DateImplement { get; private set; }
|
||||
|
||||
[DataMember]
|
||||
public int Id { get; set; }
|
||||
public virtual IceCream IceCream{ get; private set; }
|
||||
public virtual Client Client { get; private set; }
|
||||
|
@ -0,0 +1,22 @@
|
||||
using IceCreamShopContracts.DI;
|
||||
using IceCreamShopContracts.StoragesContracts;
|
||||
using IceCreamShopFileImplement.Implements;
|
||||
|
||||
namespace IceCreamShopFileImplement
|
||||
{
|
||||
public class FileImplementationExtension : IImplementationExtension
|
||||
{
|
||||
public int Priority => 1;
|
||||
|
||||
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<IIceCreamStorage, IceCreamStorage>();
|
||||
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
using IceCreamShopContracts.StoragesContracts;
|
||||
|
||||
namespace IceCreamShopFileImplement.Implements
|
||||
{
|
||||
public class BackUpInfo : IBackUpInfo
|
||||
{
|
||||
public List<T>? GetList<T>() where T : class, new()
|
||||
{
|
||||
// Получаем значения из singleton-объекта универсального свойства содержащее тип T
|
||||
var source = DataFileSingleton.GetInstance();
|
||||
return (List<T>?)source.GetType().GetProperties()
|
||||
.FirstOrDefault(x => x.PropertyType.IsGenericType && x.PropertyType.GetGenericArguments()[0] == typeof(T))
|
||||
?.GetValue(source);
|
||||
}
|
||||
public Type? GetTypeByModelInterface(string modelInterfaceName)
|
||||
{
|
||||
var assembly = typeof(BackUpInfo).Assembly;
|
||||
var types = assembly.GetTypes();
|
||||
foreach (var type in types)
|
||||
{
|
||||
if (type.IsClass && type.GetInterface(modelInterfaceName) != null)
|
||||
{
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -2,17 +2,23 @@
|
||||
using IceCreamShopContracts.ViewModels;
|
||||
using AbstractIceCreamShopDataModels.Models;
|
||||
using System.Xml.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace IceCreamShopFileImplement.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class Client : IClientModel
|
||||
{
|
||||
[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;
|
||||
|
||||
[DataMember]
|
||||
public int Id { get; private set; }
|
||||
|
||||
public static Client? Create(ClientBindingModel model)
|
||||
|
@ -7,13 +7,20 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace IceCreamShopFileImplement.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)
|
||||
{
|
||||
|
@ -7,16 +7,25 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace IceCreamShopFileImplement.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class IceCream : IIceCreamModel
|
||||
{
|
||||
[DataMember]
|
||||
public int Id { get; private set; }
|
||||
|
||||
[DataMember]
|
||||
public string IceCreamName { 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)>? _iceCreamComponents = null;
|
||||
|
||||
[DataMember]
|
||||
public Dictionary<int, (IComponentModel, int)> IceCreamComponents
|
||||
{
|
||||
get
|
||||
|
@ -2,19 +2,26 @@
|
||||
using IceCreamShopContracts.ViewModels;
|
||||
using AbstractIceCreamShopDataModels.Models;
|
||||
using System.Xml.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace IceCreamShopFileImplement.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class Implementer : IImplementerModel
|
||||
{
|
||||
[DataMember]
|
||||
public int Id { get; private set; }
|
||||
|
||||
[DataMember]
|
||||
public string ImplementerFIO { get; private set; } = string.Empty;
|
||||
|
||||
[DataMember]
|
||||
public string Password { get; private set; } = string.Empty;
|
||||
|
||||
[DataMember]
|
||||
public int WorkExperience { get; private set; }
|
||||
|
||||
[DataMember]
|
||||
public int Qualification { get; private set; }
|
||||
|
||||
public static Implementer? Create(XElement element)
|
||||
|
@ -1,22 +1,30 @@
|
||||
using AbstractIceCreamShopDataModels.Models;
|
||||
using IceCreamShopContracts.BindingModels;
|
||||
using IceCreamShopContracts.ViewModels;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace IceCreamShopFileImplement.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)
|
||||
|
@ -9,27 +9,38 @@ using System.Threading.Tasks;
|
||||
using AbstractIceCreamShopDataModels.Enums;
|
||||
using System.Xml.Linq;
|
||||
using System.Reflection.Metadata;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace IceCreamShopFileImplement.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class Order : IOrderModel
|
||||
{
|
||||
[DataMember]
|
||||
public int Id { get; private set; }
|
||||
|
||||
[DataMember]
|
||||
public int IceCreamId { get; private set; }
|
||||
|
||||
[DataMember]
|
||||
public int? ImplementerId { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public int ClientId { get; 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; } = DateTime.Now;
|
||||
|
||||
[DataMember]
|
||||
public DateTime? DateImplement { get; private set; }
|
||||
public static Order? Create(OrderBindingModel? model)
|
||||
{
|
||||
|
@ -1,17 +1,23 @@
|
||||
using IceCreamShopContracts.BindingModels;
|
||||
using IceCreamShopContracts.ViewModels;
|
||||
using AbstractIceCreamShopDataModels.Models;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace IceCreamShopListImplement.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class Client : IClientModel
|
||||
{
|
||||
[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;
|
||||
|
||||
[DataMember]
|
||||
public int Id { get; private set; }
|
||||
|
||||
public static Client? Create(ClientBindingModel model)
|
||||
|
@ -6,13 +6,20 @@ using System.Threading.Tasks;
|
||||
using IceCreamShopContracts.BindingModels;
|
||||
using IceCreamShopContracts.ViewModels;
|
||||
using AbstractIceCreamShopDataModels.Models;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace IceCreamShopListImplement.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)
|
||||
{
|
||||
|
@ -4,17 +4,26 @@ using IceCreamShopContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
namespace IceCreamShopListImplement.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class IceCream : IIceCreamModel
|
||||
{
|
||||
[DataMember]
|
||||
public int Id { get; private set; }
|
||||
|
||||
[DataMember]
|
||||
public string IceCreamName { get; private set; } = string.Empty;
|
||||
|
||||
[DataMember]
|
||||
public double Price { get; private set; }
|
||||
|
||||
[DataMember]
|
||||
public Dictionary<int, (IComponentModel, int)> IceCreamComponents
|
||||
{
|
||||
get;
|
||||
|
@ -1,19 +1,26 @@
|
||||
using IceCreamShopContracts.BindingModels;
|
||||
using IceCreamShopContracts.ViewModels;
|
||||
using AbstractIceCreamShopDataModels.Models;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace IceCreamShopListImplement.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class Implementer : IImplementerModel
|
||||
{
|
||||
[DataMember]
|
||||
public int Id { get; private set; }
|
||||
|
||||
[DataMember]
|
||||
public string ImplementerFIO { get; private set; } = string.Empty;
|
||||
|
||||
[DataMember]
|
||||
public string Password { get; private set; } = string.Empty;
|
||||
|
||||
[DataMember]
|
||||
public int WorkExperience { get; private set; }
|
||||
|
||||
[DataMember]
|
||||
public int Qualification { get; private set; }
|
||||
|
||||
public static Implementer? Create(ImplementerBindingModel model)
|
||||
|
@ -1,21 +1,29 @@
|
||||
using AbstractIceCreamShopDataModels.Models;
|
||||
using IceCreamShopContracts.BindingModels;
|
||||
using IceCreamShopContracts.ViewModels;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace IceCreamShopListImplement.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)
|
||||
|
@ -9,27 +9,38 @@ using AbstractIceCreamShopDataModels.Models;
|
||||
using AbstractIceCreamShopDataModels.Enums;
|
||||
using System.Data;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace IceCreamShopListImplement.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class Order : IOrderModel
|
||||
{
|
||||
[DataMember]
|
||||
public int Id { get; private set; }
|
||||
|
||||
[DataMember]
|
||||
public int IceCreamId { 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; } = DateTime.Now;
|
||||
|
||||
[DataMember]
|
||||
public DateTime? DateImplement { get; private set; }
|
||||
|
||||
public static Order? Create (OrderBindingModel? model)
|
||||
|
Loading…
Reference in New Issue
Block a user