-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCart.cs
124 lines (99 loc) · 3.73 KB
/
Cart.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
using ShopWebData.Code;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
namespace ShopWebData
{
public class Cart : INotifyPropertyChanged
{
[Key]
public int Id { get; set; }
public DiscountType Discount { get; set; }
public string BuyerId { get; set; }
public User Buyer { get; set; }
[Required]
public StatusEnum Status { get; set; } = StatusEnum.InCart;
[Required]
public bool Paid { get; set; } = false;
public bool? OperatorViewed { get; set; } = false;
[Required]
public Status CartStatus { get; set; } = new Status();
public List<CartItem> CartItems { get; set; } = new List<CartItem>();
public List<Gift> Gifts { get; set; } = new List<Gift>();
public Adress ShopAdress { get; set; }
public int? ShopId { get; set; }
public Shop Shop { get; set; }
public string Adress { get; set; }
public string Comment { get; set; }
[Column(TypeName = "decimal(7, 3)")]
public decimal DeliveryPrice { get; set; }
[NotMapped]
public string FullAdress {
get
{
string fullAdress = "";
string AdressType = ShopAdress?.AdressType;
string Name = ShopAdress?.Name;
string Zones = ShopAdress?.Zones;
string Parent = ShopAdress?.Parent?.Name;
if (!string.IsNullOrWhiteSpace(Parent))
{
fullAdress += Parent + " ";
}
if (!string.IsNullOrWhiteSpace(AdressType))
{
fullAdress += AdressType + " ";
}
if (!string.IsNullOrWhiteSpace(Name))
{
fullAdress += Name + " ";
}
if (!string.IsNullOrWhiteSpace(Adress))
{
fullAdress += Adress + " ";
}
if (!string.IsNullOrWhiteSpace(Zones))
{
fullAdress += Zones;
}
return fullAdress;
}
}
public string ShopComment { get; set; }
public decimal Sum => CartItems.Sum(item => item.Sum);
public decimal DollarsSum => CartItems.Sum(item => item.DollarsSum);
public decimal DollarsFinalSum => CartItems.Sum(item => item.DollarsFinalSum);
public decimal FinalSum => CartItems.Sum(item => item.FinalSum);
public decimal FinalSumWithDelivery => CartItems.Sum(item => item.FinalSum) + DeliveryPrice;
public string DeliveryTime { get; set; }
public DeliveryType DeliveryType { get; set; }
#pragma warning disable 0067
public event PropertyChangedEventHandler PropertyChanged;
#pragma warning restore 0067
// User
public string FullName { get; set; }
public string PhoneNumber { get; set; }
}
[TypeConverter(typeof(EnumDescriptionTypeConverter))]
public enum StatusEnum
{
[Description("В корзине")]
InCart = 1,
[Description("Оформлен")]
Formalized = 3,
[Description("Отредактирован пользователем")]
UserEdited = 4,
[Description("В работе")]
InWork = 5,
[Description("Изменен")]
Edited = 6,
[Description("Выполнен")]
Done = 7,
[Description("Отменен магазином")]
ShopsCanceled = 8,
[Description("Отменен")]
Canceled = 9
}
}