2016-12-17 14:41:16 +01:00
|
|
|
|
using Microsoft.eShopOnContainers.WebMVC.Models.Annotations;
|
2017-01-30 15:46:43 +01:00
|
|
|
|
using Newtonsoft.Json;
|
2016-12-17 14:41:16 +01:00
|
|
|
|
using System;
|
2016-10-10 21:52:57 -07:00
|
|
|
|
using System.Collections.Generic;
|
2016-12-30 16:44:36 +01:00
|
|
|
|
using System.ComponentModel;
|
2016-12-17 14:41:16 +01:00
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
2016-10-10 21:52:57 -07:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.eShopOnContainers.WebMVC.Models
|
|
|
|
|
{
|
|
|
|
|
public class Order
|
|
|
|
|
{
|
2016-12-17 14:41:16 +01:00
|
|
|
|
public Order() {
|
2016-11-02 20:41:12 +01:00
|
|
|
|
OrderItems = new List<OrderItem>();
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-17 14:41:16 +01:00
|
|
|
|
public string OrderNumber {get;set;}
|
|
|
|
|
|
|
|
|
|
public DateTime Date {get;set;}
|
|
|
|
|
|
|
|
|
|
public string Status { get; set; }
|
|
|
|
|
|
|
|
|
|
public decimal Total {get;set;}
|
2016-12-30 16:44:36 +01:00
|
|
|
|
|
2016-12-17 14:41:16 +01:00
|
|
|
|
[Required]
|
|
|
|
|
public string City { get; set; }
|
|
|
|
|
[Required]
|
|
|
|
|
public string Street { get; set; }
|
|
|
|
|
[Required]
|
|
|
|
|
public string State { get; set; }
|
|
|
|
|
[Required]
|
|
|
|
|
public string Country { get; set; }
|
|
|
|
|
|
|
|
|
|
public string ZipCode { get; set; }
|
|
|
|
|
[Required]
|
2016-12-30 16:44:36 +01:00
|
|
|
|
[DisplayName("Card number")]
|
2016-12-17 14:41:16 +01:00
|
|
|
|
public string CardNumber { get; set; }
|
|
|
|
|
[Required]
|
2016-12-30 16:44:36 +01:00
|
|
|
|
[DisplayName("Cardholder name")]
|
2016-12-17 14:41:16 +01:00
|
|
|
|
public string CardHolderName { get; set; }
|
|
|
|
|
|
|
|
|
|
public DateTime CardExpiration { get; set; }
|
|
|
|
|
[RegularExpression(@"(0[1-9]|1[0-2])\/[0-9]{2}", ErrorMessage = "Expiration should match a valid MM/YY value")]
|
2016-12-20 12:22:28 +01:00
|
|
|
|
[CardExpiration(ErrorMessage = "The card is expired"), Required]
|
2016-12-30 16:44:36 +01:00
|
|
|
|
[DisplayName("Card expiration")]
|
2016-12-17 14:41:16 +01:00
|
|
|
|
public string CardExpirationShort { get; set; }
|
|
|
|
|
[Required]
|
2016-12-30 16:44:36 +01:00
|
|
|
|
[DisplayName("Card security number")]
|
2016-12-17 14:41:16 +01:00
|
|
|
|
public string CardSecurityNumber { get; set; }
|
|
|
|
|
|
|
|
|
|
public int CardTypeId { get; set; }
|
|
|
|
|
|
|
|
|
|
public string Buyer { get; set; }
|
|
|
|
|
|
|
|
|
|
public List<OrderItem> OrderItems { get; }
|
|
|
|
|
|
2017-03-03 12:03:31 +01:00
|
|
|
|
[Required]
|
|
|
|
|
public Guid RequestId { get; set; }
|
|
|
|
|
|
|
|
|
|
|
2016-12-17 14:41:16 +01:00
|
|
|
|
public void CardExpirationShortFormat()
|
2016-10-10 21:52:57 -07:00
|
|
|
|
{
|
2016-12-17 14:41:16 +01:00
|
|
|
|
CardExpirationShort = CardExpiration.ToString("MM/yy");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void CardExpirationApiFormat()
|
|
|
|
|
{
|
|
|
|
|
var month = CardExpirationShort.Split('/')[0];
|
|
|
|
|
var year = $"20{CardExpirationShort.Split('/')[1]}";
|
|
|
|
|
|
|
|
|
|
CardExpiration = new DateTime(int.Parse(year), int.Parse(month), 1);
|
2016-10-10 21:52:57 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-12-17 14:41:16 +01:00
|
|
|
|
|
|
|
|
|
public enum CardType
|
2016-10-31 17:56:24 +01:00
|
|
|
|
{
|
2016-12-17 14:41:16 +01:00
|
|
|
|
AMEX = 1
|
2016-10-31 17:56:24 +01:00
|
|
|
|
}
|
2016-10-10 21:52:57 -07:00
|
|
|
|
}
|