1: //using EntityFramework.Triggers;
2: using System;
3: using System.Collections.Generic;
4: using System.ComponentModel.DataAnnotations;
5: using System.ComponentModel.DataAnnotations.Schema;
6:
7: namespace Ia.Ngn.Cl.Model
8: {
9: ////////////////////////////////////////////////////////////////////////////
10:
11: /// <summary publish="true">
12: /// Service Request Ont Detail Entity Framework class for Next Generation Network (NGN) entity model.
13: /// </summary>
14: ///
15: /// <remarks>
16: /// Copyright © 2006-2018 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
17: ///
18: /// This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
19: /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
20: ///
21: /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
22: /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
23: ///
24: /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
25: ///
26: /// Copyright notice: This notice may not be removed or altered from any source distribution.
27: /// </remarks>
28: public class ServiceRequestOntDetail //: ITriggerable
29: {
30: /// <summary/>
31: public ServiceRequestOntDetail()
32: {
33: //this.Triggers().Inserting += entry => { TriggeredInstanceQueue.Enqueue(entry.Entity); };
34: //this.Triggers().Updating += entry => { TriggeredInstanceQueue.Enqueue(entry.Entity); };
35: //this.Triggers().Deleting += entry => { TriggeredInstanceQueue.Enqueue(entry.Entity); };
36: }
37:
38: /// <summary/>
39: [Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
40: public string Id { get; set; }
41: /// <summary/>
42: public int ServiceType { get; set; }
43: /// <summary/>
44: public int ServicePosition { get; set; }
45: /// <summary/>
46: public string Service { get; set; }
47: /// <summary/>
48: public DateTime Created { get; set; }
49: /// <summary/>
50: public DateTime Updated { get; set; }
51:
52: /// <summary/>
53: public virtual ServiceRequestOnt ServiceRequestOnt { get; set; }
54:
55: /// <summary/>
56: [NotMapped]
57: public static Queue<ServiceRequestOntDetail> TriggeredInstanceQueue = new Queue<ServiceRequestOntDetail>();
58:
59: ////////////////////////////////////////////////////////////////////////////
60:
61: /// <summary>
62: ///
63: /// </summary>
64: public void Copy(ServiceRequestOntDetail serviceRequestOntDetail)
65: {
66: this.ServiceRequestOnt = serviceRequestOntDetail.ServiceRequestOnt;
67: this.Id = serviceRequestOntDetail.Id;
68: this.Created = serviceRequestOntDetail.Created;
69: this.Updated = serviceRequestOntDetail.Updated;
70:
71: this.ServiceType = serviceRequestOntDetail.ServiceType;
72: this.ServicePosition = serviceRequestOntDetail.ServicePosition;
73: this.Service = serviceRequestOntDetail.Service;
74: }
75:
76: ////////////////////////////////////////////////////////////////////////////
77:
78: /// <summary>
79: ///
80: /// </summary>
81: public bool Update(ServiceRequestOntDetail updatedServiceRequestOntDetail)
82: {
83: // below: this will not update Id, Created
84: bool updated;
85:
86: updated = false;
87:
88: if (this.ServiceRequestOnt != updatedServiceRequestOntDetail.ServiceRequestOnt) { this.ServiceRequestOnt = updatedServiceRequestOntDetail.ServiceRequestOnt; updated = true; }
89:
90: if (this.ServiceType != updatedServiceRequestOntDetail.ServiceType) { this.ServiceType = updatedServiceRequestOntDetail.ServiceType; updated = true; }
91: if (this.ServicePosition != updatedServiceRequestOntDetail.ServicePosition) { this.ServicePosition = updatedServiceRequestOntDetail.ServicePosition; updated = true; }
92: if (this.Service != updatedServiceRequestOntDetail.Service) { this.Service = updatedServiceRequestOntDetail.Service; updated = true; }
93:
94: if (updated) this.Updated = DateTime.UtcNow.AddHours(3);
95:
96: return updated;
97: }
98:
99: ////////////////////////////////////////////////////////////////////////////
100: ////////////////////////////////////////////////////////////////////////////
101: }
102:
103: ////////////////////////////////////////////////////////////////////////////
104: ////////////////////////////////////////////////////////////////////////////
105: }