2023-05-15 12:00:40 -07:00
|
|
|
|
using FurnitureAssemblyContracts.BindingModels;
|
|
|
|
|
using FurnitureAssemblyContracts.ViewModels;
|
|
|
|
|
using FurnitureAssemblyDataModels.Enums;
|
|
|
|
|
using FurnitureAssemblyDataModels.Models;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace FurnitureAssemblyDatabaseImplement.Models
|
|
|
|
|
{
|
|
|
|
|
public class OrderInfo : IOrderInfoModel
|
|
|
|
|
{
|
|
|
|
|
public int Id { get; set; }
|
|
|
|
|
[Required]
|
|
|
|
|
public string CustomerName { get; set; } = string.Empty;
|
|
|
|
|
[Required]
|
|
|
|
|
public PaymentType PaymentType { get; set; } = PaymentType.Неизвестен;
|
|
|
|
|
[Required]
|
|
|
|
|
public DateTime DateCreate { get; set; }
|
|
|
|
|
[Required]
|
|
|
|
|
public double Sum { get; set; }
|
|
|
|
|
[Required]
|
|
|
|
|
public int UserId { get; set; }
|
|
|
|
|
public virtual User User { get; set; }
|
|
|
|
|
public static OrderInfo? Create(OrderInfoBindingModel? model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return new OrderInfo()
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
CustomerName = model.CustomerName,
|
|
|
|
|
PaymentType = model.PaymentType,
|
|
|
|
|
Sum = model.Sum,
|
2023-05-16 13:17:21 -07:00
|
|
|
|
DateCreate = DateTime.Now.ToUniversalTime(),
|
2023-05-15 12:00:40 -07:00
|
|
|
|
UserId = model.UserId
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
public void Update(OrderInfoBindingModel? model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
CustomerName = model.CustomerName;
|
|
|
|
|
PaymentType = model.PaymentType;
|
|
|
|
|
UserId = model.UserId;
|
|
|
|
|
}
|
|
|
|
|
public OrderInfoViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
Id = Id,
|
|
|
|
|
CustomerName = CustomerName,
|
|
|
|
|
PaymentType = PaymentType,
|
|
|
|
|
DateCreate = DateCreate,
|
|
|
|
|
Sum = Sum,
|
|
|
|
|
UserId = UserId,
|
|
|
|
|
UserName = User.Name
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|