1: using System;
2: using System.Collections.Generic;
3: using System.ComponentModel.DataAnnotations;
4: using System.ComponentModel.DataAnnotations.Schema;
5: using System.Linq;
6:
7: namespace Ia.Ngn.Cl.Model
8: {
9: ////////////////////////////////////////////////////////////////////////////
10:
11: /// <summary publish="true">
12: /// Access 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 partial class Access
29: {
30: /// <summary/>
31: public Access() { }
32:
33: /// <summary/>
34: [Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
35: public string Id { get; set; }
36:
37: /// <summary/>
38: public int Olt { get; set; }
39: /// <summary/>
40: public int Pon { get; set; }
41: /// <summary/>
42: public int Ont { get; set; }
43: /// <summary/>
44: public string Odf { get; set; }
45: /// <summary/>
46: public int AreaId { get; set; }
47: /// <summary/>
48: public string Block { get; set; }
49: /// <summary/>
50: public string Street { get; set; }
51: /// <summary/>
52: public string PremisesOld { get; set; }
53: /// <summary/>
54: public string PremisesNew { get; set; }
55: /// <summary/>
56: public string Paci { get; set; }
57: /// <summary/>
58: public string Note { get; set; }
59: /// <summary/>
60: public DateTime Created { get; set; }
61: /// <summary/>
62: public DateTime Updated { get; set; }
63: /// <summary/>
64: public System.Guid UserId { get; set; }
65:
66: /// <summary/>
67: public virtual ICollection<Ont> Onts { get; set; }
68:
69: /// <summary/>
70: public virtual ICollection<Ia.Ngn.Cl.Model.Huawei.EmsOnt> EmsOnts { get; set; }
71:
72: /// <summary/>
73: [NotMapped]
74: public string Name
75: {
76: get
77: {
78: return Ia.Ngn.Cl.Model.Business.Access.Name(this);
79: }
80: }
81:
82: /// <summary/>
83: [NotMapped]
84: public string Position
85: {
86: get
87: {
88: string position;
89:
90: position = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Pon.PonGroup.Olt.Id == this.Olt && o.Pon.Number == this.Pon && o.Number == this.Ont select o.Position).SingleOrDefault();
91:
92: return position;
93: }
94: }
95:
96: ////////////////////////////////////////////////////////////////////////////
97:
98: /// <summary>
99: ///
100: /// </summary>
101: [NotMapped]
102: public string Address
103: {
104: get
105: {
106: string address;
107:
108: address = (from kna in Ia.Ngn.Cl.Model.Data.Service.KuwaitNgnAreaList where kna.Id == this.AreaId select kna.Name).SingleOrDefault();
109:
110: address += ", block " + this.Block + ", street " + this.Street + ", old premises " + this.PremisesOld + ", new premises " + this.PremisesNew;
111:
112: return address;
113: }
114: }
115:
116: ////////////////////////////////////////////////////////////////////////////
117:
118: /// <summary>
119: ///
120: /// </summary>
121: [NotMapped]
122: public string ArabicAddress
123: {
124: get
125: {
126: string address;
127:
128: address = (from kna in Ia.Ngn.Cl.Model.Data.Service.KuwaitNgnAreaList
129: where kna.Id == this.AreaId
130: select kna.ArabicName).SingleOrDefault();
131:
132: address += ", قطعة " + this.Block + ", شارع " + this.Street + ", قسيمة " + this.PremisesOld + ", منزل " + this.PremisesNew;
133:
134: return address;
135: }
136: }
137:
138: ////////////////////////////////////////////////////////////////////////////
139:
140: /// <summary>
141: ///
142: /// </summary>
143: public bool Update(Access updatedAccess)
144: {
145: // below: this will not update Id, Created
146: bool updated;
147:
148: updated = false;
149:
150: if (this.AreaId != updatedAccess.AreaId) { this.AreaId = updatedAccess.AreaId; updated = true; }
151: if (this.Block != updatedAccess.Block) { this.Block = updatedAccess.Block; updated = true; }
152: //if (this.Name != updatedAccess.Name) { this.Name = updatedAccess.Name; updated = true; }
153: if (this.Odf != updatedAccess.Odf) { this.Odf = updatedAccess.Odf; updated = true; }
154: if (this.Olt != updatedAccess.Olt) { this.Olt = updatedAccess.Olt; updated = true; }
155: if (this.Ont != updatedAccess.Ont) { this.Ont = updatedAccess.Ont; updated = true; }
156: if (this.Pon != updatedAccess.Pon) { this.Pon = updatedAccess.Pon; updated = true; }
157: //if (this.Position != updatedAccess.Position) { this.Position = updatedAccess.Position; updated = true; }
158: if (this.PremisesOld != updatedAccess.PremisesOld) { this.PremisesOld = updatedAccess.PremisesOld; updated = true; }
159: if (this.PremisesNew != updatedAccess.PremisesNew) { this.PremisesNew = updatedAccess.PremisesNew; updated = true; }
160: if (this.Paci != updatedAccess.Paci) { this.Paci = updatedAccess.Paci; updated = true; }
161: if (this.Note != updatedAccess.Note) { this.Note = updatedAccess.Note; updated = true; }
162: if (this.Street != updatedAccess.Street) { this.Street = updatedAccess.Street; updated = true; }
163: if (this.UserId != updatedAccess.UserId) { this.UserId = updatedAccess.UserId; updated = true; }
164:
165: if (updated) this.Updated = DateTime.UtcNow.AddHours(3);
166:
167: return updated;
168: }
169:
170: ////////////////////////////////////////////////////////////////////////////
171: ////////////////////////////////////////////////////////////////////////////
172:
173: /// <summary>
174: ///
175: /// </summary>
176: public string ToSimpleTextString()
177: {
178: return Ia.Ngn.Cl.Model.Data.Access.ToSimpleTextString(this);
179: }
180:
181: ////////////////////////////////////////////////////////////////////////////
182: ////////////////////////////////////////////////////////////////////////////
183: }
184:
185: ////////////////////////////////////////////////////////////////////////////
186: ////////////////////////////////////////////////////////////////////////////
187: }