2024-03-05 13:13:35 +04:00
|
|
|
|
using FurnitureAssemblyContracts.BindingModels;
|
|
|
|
|
using FurnitureAssemblyContracts.ViewModels;
|
|
|
|
|
using FurnitureAssemblyDataModels.Enums;
|
|
|
|
|
using FurnitureAssemblyDataModels.Models;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Linq;
|
2024-04-29 18:16:15 +04:00
|
|
|
|
using System.Reflection;
|
2024-03-05 13:13:35 +04:00
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
2024-04-29 18:16:15 +04:00
|
|
|
|
using System.Xml.Linq;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
2024-05-14 11:56:24 +04:00
|
|
|
|
using System.Runtime.Serialization;
|
2024-03-05 13:13:35 +04:00
|
|
|
|
|
|
|
|
|
namespace FurnitureAssemblyDatabaseImplement.Models
|
|
|
|
|
{
|
2024-05-14 11:56:24 +04:00
|
|
|
|
[DataContract]
|
2024-03-05 13:13:35 +04:00
|
|
|
|
public class Order : IOrderModel
|
|
|
|
|
{
|
2024-04-29 18:16:15 +04:00
|
|
|
|
[ForeignKey("ProductId")]
|
2024-05-14 11:56:24 +04:00
|
|
|
|
[DataMember]
|
2024-04-29 18:16:15 +04:00
|
|
|
|
public int FurnitureId { get; set; }
|
2024-03-05 13:13:35 +04:00
|
|
|
|
[Required]
|
2024-05-14 11:56:24 +04:00
|
|
|
|
[DataMember]
|
2024-04-29 18:16:15 +04:00
|
|
|
|
public int Count { get; set; }
|
2024-03-05 13:13:35 +04:00
|
|
|
|
[Required]
|
2024-05-14 11:56:24 +04:00
|
|
|
|
[DataMember]
|
2024-04-29 18:16:15 +04:00
|
|
|
|
public double Sum { get; set; }
|
2024-03-05 13:13:35 +04:00
|
|
|
|
[Required]
|
2024-05-14 11:56:24 +04:00
|
|
|
|
[DataMember]
|
2024-04-29 18:16:15 +04:00
|
|
|
|
public OrderStatus Status { get; set; }
|
2024-03-05 13:13:35 +04:00
|
|
|
|
[Required]
|
2024-05-14 11:56:24 +04:00
|
|
|
|
[DataMember]
|
2024-04-29 18:16:15 +04:00
|
|
|
|
public DateTime DateCreate { get; set; }
|
2024-05-14 11:56:24 +04:00
|
|
|
|
[DataMember]
|
2024-04-29 18:16:15 +04:00
|
|
|
|
public DateTime? DateImplement { get; set; }
|
2024-05-14 11:56:24 +04:00
|
|
|
|
[DataMember]
|
2024-04-29 18:16:15 +04:00
|
|
|
|
public int Id { get; set; }
|
|
|
|
|
[Required]
|
2024-05-14 11:56:24 +04:00
|
|
|
|
[DataMember]
|
2024-04-29 18:16:15 +04:00
|
|
|
|
public int ClientId { get; private set; }
|
|
|
|
|
public virtual Client Client { get; set; }
|
2024-03-05 13:13:35 +04:00
|
|
|
|
public virtual Furniture Furniture { get; set; }
|
2024-05-14 11:56:24 +04:00
|
|
|
|
[DataMember]
|
2024-04-29 18:59:10 +04:00
|
|
|
|
public int? ImplementerId { get; private set; }
|
|
|
|
|
|
|
|
|
|
public virtual Implementer? Implementer { get; set; }
|
2024-03-05 13:13:35 +04:00
|
|
|
|
|
|
|
|
|
public static Order? Create(OrderBindingModel? model)
|
|
|
|
|
{
|
|
|
|
|
return new Order()
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
FurnitureId = model.FurnitureId,
|
|
|
|
|
Count = model.Count,
|
|
|
|
|
Sum = model.Sum,
|
|
|
|
|
Status = model.Status,
|
|
|
|
|
DateCreate = model.DateCreate,
|
2024-04-29 18:16:15 +04:00
|
|
|
|
DateImplement = model.DateImplement,
|
2024-04-29 18:59:10 +04:00
|
|
|
|
ClientId = model.ClientId,
|
|
|
|
|
ImplementerId = model.ImplementerId
|
2024-03-05 13:13:35 +04:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-29 18:16:15 +04:00
|
|
|
|
public void Update(OrderBindingModel? model)
|
2024-03-05 13:13:35 +04:00
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-04-29 18:59:10 +04:00
|
|
|
|
//Count = model.Count;
|
|
|
|
|
//Sum = model.Sum;
|
2024-03-05 13:13:35 +04:00
|
|
|
|
Status = model.Status;
|
|
|
|
|
DateImplement = model.DateImplement;
|
2024-04-29 18:59:10 +04:00
|
|
|
|
ImplementerId = model.ImplementerId;
|
2024-03-05 13:13:35 +04:00
|
|
|
|
}
|
2024-04-29 18:16:15 +04:00
|
|
|
|
|
2024-03-05 13:13:35 +04:00
|
|
|
|
public OrderViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
Id = Id,
|
|
|
|
|
FurnitureId = FurnitureId,
|
|
|
|
|
FurnitureName = Furniture.FurnitureName,
|
|
|
|
|
Count = Count,
|
|
|
|
|
Sum = Sum,
|
|
|
|
|
Status = Status,
|
|
|
|
|
DateCreate = DateCreate,
|
2024-04-29 18:16:15 +04:00
|
|
|
|
DateImplement = DateImplement,
|
|
|
|
|
ClientId = ClientId,
|
2024-04-29 18:59:10 +04:00
|
|
|
|
ClientFIO = Client.ClientFIO,
|
|
|
|
|
ImplementerId = ImplementerId,
|
|
|
|
|
ImplementerFIO = Implementer?.ImplementerFIO
|
2024-03-05 13:13:35 +04:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|