1: using System;
2: using System.Collections.Generic;
3: using System.ComponentModel.DataAnnotations.Schema;
4: using System.Data.Entity;
5: using System.Linq;
6:
7: namespace Ia.Ngn.Cl.Model
8: {
9: ////////////////////////////////////////////////////////////////////////////
10:
11: /// <summary publish="true">
12: /// Report Entity Framework class for Next Generation Network (NGN) entity model.
13: /// </summary>
14: ///
15: /// <remarks>
16: /// Copyright © 2006-2019 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 partial class Report
29: {
30: /// <summary/>
31: public Report()
32: {
33: // this.ReportHistories = new List<ReportHistory>();
34: }
35:
36: /// <summary/>
37: public int Id { get; set; }
38:
39: /// <summary/>
40: public string Service { get; set; }
41:
42: /// <summary/>
43: public int ServiceType { get; set; }
44:
45: /// <summary/>
46: public int State { get; set; }
47:
48: /// <summary/>
49: public int Status { get; set; }
50:
51: /// <summary/>
52: public int Category { get; set; }
53:
54: /// <summary/>
55: public int Area { get; set; }
56:
57: /// <summary/>
58: public int Priority { get; set; }
59:
60: /// <summary/>
61: public int Severity { get; set; }
62:
63: /// <summary/>
64: public string Detail { get; set; }
65:
66: /// <summary/>
67: public string Contact { get; set; }
68:
69: /// <summary/>
70: public string Note { get; set; }
71:
72: /// <summary/>
73: public DateTime Created { get; set; }
74:
75: /// <summary/>
76: public DateTime Updated { get; set; }
77:
78: /// <summary/>
79: public System.Guid UserId { get; set; }
80:
81: /// <summary/>
82: public virtual ICollection<ReportHistory> ReportHistories { get; set; }
83:
84: ////////////////////////////////////////////////////////////////////////////
85:
86: /// <summary>
87: ///
88: /// </summary>
89: [NotMapped]
90: public bool StatusIsOpen
91: {
92: get
93: {
94: return this.Status == (int)Ia.Ngn.Cl.Model.Business.Report.Status.Open;
95: }
96: }
97:
98: ////////////////////////////////////////////////////////////////////////////
99:
100: /// <summary>
101: ///
102: /// </summary>
103: [NotMapped]
104: public ReportHistory LastReportHistory
105: {
106: get
107: {
108: ReportHistory reportHistory;
109:
110: reportHistory = null;
111:
112: if (this.ReportHistories != null)
113: {
114: if (this.ReportHistories.Count > 0)
115: {
116: reportHistory = this.ReportHistories.Skip(this.ReportHistories.Count - 1).FirstOrDefault();
117: }
118: else reportHistory = null;
119: }
120: else reportHistory = null;
121:
122: return reportHistory;
123: }
124: }
125:
126: ////////////////////////////////////////////////////////////////////////////
127:
128: /// <summary>
129: ///
130: /// </summary>
131: [NotMapped]
132: public ReportHistory SecondToLastReportHistory
133: {
134: get
135: {
136: ReportHistory reportHistory;
137:
138: reportHistory = null;
139:
140: if (this.ReportHistories != null)
141: {
142: if (this.ReportHistories.Count > 1)
143: {
144: reportHistory = this.ReportHistories.Skip(this.ReportHistories.Count - 2).FirstOrDefault();
145: }
146: else reportHistory = null;
147: }
148: else reportHistory = null;
149:
150: return reportHistory;
151: }
152: }
153:
154: ////////////////////////////////////////////////////////////////////////////
155:
156: /// <summary>
157: ///
158: /// </summary>
159: public bool UpdateMigrated(Report updatedReport)
160: {
161: // below: this will not update Id, Created
162: bool updated;
163:
164: updated = false;
165:
166: if (this.Area != updatedReport.Area) { this.Area = updatedReport.Area; updated = true; }
167: if (this.Category != updatedReport.Category) { this.Category = updatedReport.Category; updated = true; }
168: if (this.Contact != updatedReport.Contact) { this.Contact = updatedReport.Contact; updated = true; }
169: if (this.Detail != updatedReport.Detail) { this.Detail = updatedReport.Detail; updated = true; }
170: if (this.Note != updatedReport.Note) { this.Note = updatedReport.Note; updated = true; }
171: if (this.Priority != updatedReport.Priority) { this.Priority = updatedReport.Priority; updated = true; }
172: if (this.Service != updatedReport.Service) { this.Service = updatedReport.Service; updated = true; }
173:
174: if (this.ServiceType != updatedReport.ServiceType) { this.ServiceType = updatedReport.ServiceType; updated = true; }
175: if (this.ReportHistories != updatedReport.ReportHistories) { this.ReportHistories = updatedReport.ReportHistories; updated = true; }
176: if (this.Severity != updatedReport.Severity) { this.Severity = updatedReport.Severity; updated = true; }
177: if (this.State != updatedReport.State) { this.State = updatedReport.State; updated = true; }
178: if (this.Status != updatedReport.Status) { this.Status = updatedReport.Status; updated = true; }
179:
180: if (this.UserId != updatedReport.UserId) { this.UserId = updatedReport.UserId; updated = true; }
181:
182: // below: this is an update of migrated data
183: if (this.Created != updatedReport.Created) { this.Created = updatedReport.Created; updated = true; }
184: if (this.Updated != updatedReport.Updated) { this.Updated = updatedReport.Updated; updated = true; }
185:
186: //if (updated) this.Updated = DateTime.UtcNow.AddHours(3);
187:
188: return updated;
189: }
190:
191: ////////////////////////////////////////////////////////////////////////////
192: ////////////////////////////////////////////////////////////////////////////
193: }
194: }