добавление атрибутов

This commit is contained in:
Мк Игорь 2023-05-21 20:08:34 +04:00
parent 4fa51bef04
commit 77eea08265
13 changed files with 89 additions and 0 deletions

View File

@ -3,16 +3,22 @@ using BlacksmithWorkshopContracts.ViewModels;
using BlacksmithWorkshopDataModels.Models;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
namespace BlacksmithWorkshopDatabaseImplement.Models
{
[DataContract]
public class Client : IClientModel
{
[DataMember]
public int Id { get; private set; }
[DataMember]
[Required]
public string ClientFIO { get; private set; } = string.Empty;
[DataMember]
[Required]
public string Email { get; private set; } = string.Empty;
[DataMember]
[Required]
public string Password { get; private set; } = string.Empty;
[ForeignKey("ClientId")]

View File

@ -3,14 +3,19 @@ using BlacksmithWorkshopContracts.ViewModels;
using BlacksmithWorkshopDataModels.Models;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
namespace BlacksmithWorkshopDatabaseImplement.Models
{
[DataContract]
public class Component : IComponentModel
{
[DataMember]
public int Id {get; private set;}
[DataMember]
[Required]
public string ComponentName { get; private set; } = string.Empty;
[DataMember]
[Required]
public double Cost { get; set; }
[ForeignKey("ComponentId")]

View File

@ -3,18 +3,25 @@ using BlacksmithWorkshopContracts.ViewModels;
using BlacksmithWorkshopDataModels.Models;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
namespace BlacksmithWorkshopDatabaseImplement.Models
{
[DataContract]
public class Implementer : IImplementerModel
{
[DataMember]
public int Id { get; private set; }
[DataMember]
[Required]
public string ImplementerFIO { get; private set; } = string.Empty;
[DataMember]
[Required]
public string Password { get; private set; } = string.Empty;
[DataMember]
[Required]
public int WorkExperience { get; private set; }
[DataMember]
[Required]
public int Qualification { get; private set; }
//Привязываем исполнителя к заказам один ко многим

View File

@ -3,14 +3,19 @@ using BlacksmithWorkshopContracts.ViewModels;
using BlacksmithWorkshopDataModels.Models;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
namespace BlacksmithWorkshopDatabaseImplement.Models
{
[DataContract]
public class Manufacture : IManufactureModel
{
[DataMember]
public int Id { get; set; }
[DataMember]
[Required]
public string ManufactureName { get; set; } = string.Empty;
[DataMember]
[Required]
public double Price { get; set; }
private Dictionary<int, (IComponentModel, int)>? _manufactureComponents = null;

View File

@ -1,14 +1,20 @@
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
namespace BlacksmithWorkshopDatabaseImplement.Models
{
[DataContract]
public class ManufactureComponent
{
[DataMember]
public int Id { get; set; }
[DataMember]
[Required]
public int ManufactureId { get; set; }
[DataMember]
[Required]
public int ComponentId { get; set; }
[DataMember]
[Required]
public int Count { get; set; }
public virtual Component Component { get; set; } = new();

View File

@ -2,20 +2,27 @@
using BlacksmithWorkshopContracts.ViewModels;
using BlacksmithWorkshopDataModels.Models;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
namespace BlacksmithWorkshopDatabaseImplement.Models
{
[DataContract]
public class MessageInfo : IMessageInfoModel
{
[DataMember]
[Key]
public string MessageId { get; private set; } = string.Empty;
public int? ClientId { get; private set; }
[DataMember]
[Required]
public string SenderName { get; private set; } = string.Empty;
[DataMember]
[Required]
public DateTime DateDelivery { get; private set; } = DateTime.Now;
[DataMember]
[Required]
public string Subject { get; private set; } = string.Empty;
[DataMember]
[Required]
public string Body { get; private set; } = string.Empty;
public Client? Client { get; private set; }

View File

@ -3,23 +3,33 @@ using BlacksmithWorkshopContracts.ViewModels;
using BlacksmithWorkshopDataModels.Enums;
using BlacksmithWorkshopDataModels.Models;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
namespace BlacksmithWorkshopDatabaseImplement.Models
{
[DataContract]
public class Order : IOrderModel
{
[DataMember]
public int Id { get; set; }
[DataMember]
[Required]
public int ManufactureId { get; set; }
[DataMember]
[Required]
public int Count { get; private set; }
[DataMember]
[Required]
public double Sum { get; private set; }
[DataMember]
[Required]
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
[DataMember]
[Required]
public DateTime DateCreate { get; private set; } = DateTime.Now;
[DataMember]
public DateTime? DateImplement { get; private set; }
[DataMember]
[Required]
public int ClientId { get; private set; }
[Required]

View File

@ -1,15 +1,21 @@
using BlacksmithWorkshopContracts.BindingModels;
using BlacksmithWorkshopContracts.ViewModels;
using BlacksmithWorkshopDataModels.Models;
using System.Runtime.Serialization;
using System.Xml.Linq;
namespace BlacksmithWorkshopFileImplement.Models
{
[DataContract]
public class Client : IClientModel
{
[DataMember]
public int Id { get; private set; }
[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)
{

View File

@ -1,15 +1,20 @@
using BlacksmithWorkshopContracts.BindingModels;
using BlacksmithWorkshopContracts.ViewModels;
using BlacksmithWorkshopDataModels.Models;
using System.Runtime.Serialization;
using System.Xml.Linq;
namespace BlacksmithWorkshopFileImplement.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)
{

View File

@ -1,16 +1,23 @@
using BlacksmithWorkshopContracts.BindingModels;
using BlacksmithWorkshopContracts.ViewModels;
using BlacksmithWorkshopDataModels.Models;
using System.Runtime.Serialization;
using System.Xml.Linq;
namespace BlacksmithWorkshopFileImplement.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)
{

View File

@ -1,16 +1,22 @@
using BlacksmithWorkshopContracts.BindingModels;
using BlacksmithWorkshopContracts.ViewModels;
using BlacksmithWorkshopDataModels.Models;
using System.Runtime.Serialization;
using System.Xml.Linq;
namespace BlacksmithWorkshopFileImplement.Models
{
[DataContract]
public class Manufacture : IManufactureModel
{
[DataMember]
public int Id { get; private set; }
[DataMember]
public string ManufactureName { 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)>? _manufactureComponents = null;
[DataMember]
public Dictionary<int, (IComponentModel, int)> ManufactureComponents
{
get

View File

@ -1,17 +1,25 @@
using BlacksmithWorkshopContracts.BindingModels;
using BlacksmithWorkshopContracts.ViewModels;
using BlacksmithWorkshopDataModels.Models;
using System.Runtime.Serialization;
using System.Xml.Linq;
namespace BlacksmithWorkshopFileImplement.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)
{

View File

@ -3,20 +3,31 @@ using BlacksmithWorkshopContracts.ViewModels;
using BlacksmithWorkshopDataModels.Enums;
using BlacksmithWorkshopDataModels.Models;
using System.Reflection;
using System.Runtime.Serialization;
using System.Xml.Linq;
namespace BlacksmithWorkshopFileImplement.Models
{
[DataContract]
public class Order : IOrderModel
{
[DataMember]
public int Id { get; private set; }
[DataMember]
public int ManufactureId {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; }
[DataMember]
public int ClientId { get; private set; }
[DataMember]
public int? ImplementerId { get; set; }
public static Order? Create(OrderBindingModel? model)
{