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 Type Entity Framework class for Next Generation Network (NGN) entity model.
13: /// </summary>
14: ///
15: /// <remarks>
16: /// Copyright © 2006-2017 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 ServiceRequestType //: ITriggerable
29: {
30: /// <summary/>
31: public ServiceRequestType()
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 int Id { get; set; }
41: /// <summary/>
42: public int TypeId { get; set; }
43: /// <summary/>
44: public string Value { get; set; }
45:
46: /// <summary/>
47: public DateTime Created { get; set; }
48: /// <summary/>
49: public DateTime Updated { get; set; }
50: /// <summary/>
51: public System.Guid UserId { get; set; }
52:
53: /// <summary/>
54: public virtual ServiceRequest ServiceRequest { get; set; }
55:
56: /// <summary/>
57: [NotMapped]
58: public static Queue<ServiceRequestType> TriggeredInstanceQueue = new Queue<ServiceRequestType>();
59:
60: ////////////////////////////////////////////////////////////////////////////
61:
62: /// <summary>
63: ///
64: /// </summary>
65: public bool Update(ServiceRequestType updatedServiceRequestType)
66: {
67: // below: this will not update Id, Created
68: bool updated;
69:
70: updated = false;
71:
72: if (this.TypeId != updatedServiceRequestType.TypeId) { this.TypeId = updatedServiceRequestType.TypeId; updated = true; }
73: if (this.Value != updatedServiceRequestType.Value) { this.Value = updatedServiceRequestType.Value; updated = true; }
74: if (this.UserId != updatedServiceRequestType.UserId) { this.UserId = updatedServiceRequestType.UserId; updated = true; }
75:
76: // below: ??
77: //if (this.ServiceRequest == null || this.ServiceRequest != updatedServiceRequestType.ServiceRequest) { this.ServiceRequest = updatedServiceRequestType.ServiceRequest; updated = true; }
78:
79: if (updated) this.Updated = DateTime.UtcNow.AddHours(3);
80:
81: return updated;
82: }
83:
84: ////////////////////////////////////////////////////////////////////////////
85: ////////////////////////////////////////////////////////////////////////////
86: }
87:
88: ////////////////////////////////////////////////////////////////////////////
89: ////////////////////////////////////////////////////////////////////////////
90: }