using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using DiplomovaPrace.Contracts.Addresses;
using DiplomovaPrace.Contracts.Orders.ViewModels;

namespace DiplomovaPrace.Contracts.Orders.InputModels
{
	[DataContract]
	public class OrderIM
	{
		[DataMember(Order = 1)]
		public int OrderID { get; set; }

		[DataMember(Order = 2)]
		[Required]
		public int OrderStateID { get; set; }

		[DataMember(Order = 3)]
		[Required]
		public int PaymentTypeID { get; set; }

		[DataMember(Order = 4)]
		[Required]
		public int PaymentStateID { get; set; }

		[DataMember(Order = 5)]
		[Required]
		public int DeliveryTypeID { get; set; }

		// Počítá se na frontendu => zbytečná property
		// Počítá se i zvlašť na backendu kvůli bezpečnosti
		[DataMember(Order = 6)]
		public decimal TotalPrice { get; set; }

		[DataMember(Order = 7)]
		public DateTime OrderedDate { get; set; }

		[DataMember(Order = 8)]
		[ValidateComplexType]
		public List<OrderItemIM> OrderItems { get; set; } = new();

		[DataMember(Order = 9)]
		[ValidateComplexType]
		public AddressDto InvoicingAddress { get; set; }

		[DataMember(Order = 10)]
		[ValidateComplexType]
		public AddressDto DeliveryAddress { get; set; }

		[DataMember(Order = 11)]
		[Required(ErrorMessage = "Vyberte, prosím, fakturační adresu!")]
		[Range(1, int.MaxValue, ErrorMessage = "Vyberte, prosím, fakturační adresu!")]
		public int InvoicingAddressID { get; set; }

		[DataMember(Order = 12)]
		public int DeliveryAddressID { get; set; }

		[DataMember(Order = 13)]
		public LoginAccountVM LoginAccount { get; set; }

		[DataMember(Order = 14)]
		public string CustomerEmail { get; set; }
	}
}
