This repository has been archived by the owner on Feb 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Customer.cs
86 lines (66 loc) · 2.37 KB
/
Customer.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
using Postulate.Orm.Abstract;
using Postulate.Orm.Attributes;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data;
namespace Sample.Models
{
[TrackChanges(IgnoreProperties = "ModifiedBy,DateModified")]
public class Customer : BaseTable
{
[Postulate.Orm.Attributes.ForeignKey(typeof(Organization))]
public int OrganizationId { get; set; }
[MaxLength(100)]
[Required]
public string LastName { get; set; }
[MaxLength(100)]
[Required]
public string FirstName { get; set; }
[MaxLength(100)]
public string Address { get; set; }
[MaxLength(50)]
public string City { get; set; }
[MaxLength(2)]
public string State { get; set; }
[MaxLength(5)]
public string ZipCode { get; set; }
//test properties added to demo schema merge
/*
[MaxLength(50)]
public string Email { get; set; }
[MaxLength(50)]
public string Phone1 { get; set; }
[MaxLength(50)]
public string Phone2 { get; set; }
*/
[Postulate.Orm.Attributes.ForeignKey(typeof(CustomerType))]
public int TypeId { get; set; }
[Postulate.Orm.Attributes.ForeignKey(typeof(Region))]
public int RegionId { get; set; }
[Postulate.Orm.Attributes.ForeignKey(typeof(Region))]
public int? OtherRegionId { get; set; }
[NotMapped]
public string CustomerTypeName { get; set; }
[NotMapped]
public string RegionName { get; set; }
public override bool AllowDelete(IDbConnection connection, SqlDb<int> db, out string message)
{
if (db.UserName.Equals("adamosoftware@gmail.com"))
{
message = "Adam is not allowed to delete customers.";
return false;
}
message = null;
return true;
}
/*
test after adding Email, Phone1, and Phone2 fields
public override IEnumerable<string> GetValidationErrors(IDbConnection connection, SaveAction action)
{
if (string.IsNullOrEmpty(Email) && string.IsNullOrEmpty(Phone1) && string.IsNullOrEmpty(Phone2))
{
yield return "Email, Phone1, or Phone2 must be provided";
}
}*/
}
}