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: /// ONT-SERVICEVOIP 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 partial class OntServiceVoip
29: {
30: /// <summary/>
31: public OntServiceVoip() { }
32:
33: /// <summary/>
34: [Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
35: public string Id { get; set; }
36: /// <summary/>
37: public int StateId { get; set; }
38: /// <summary/>
39: public int Svlan { get; set; }
40: /// <summary/>
41: public string Ip { get; set; }
42: /// <summary/>
43: public string FtpIp { get; set; }
44: /// <summary/>
45: public string MgcIp { get; set; }
46: /// <summary/>
47: public string MgcSecondaryIp { get; set; }
48: /// <summary/>
49: public string ConfiguratinFile { get; set; }
50: /// <summary/>
51: public string Customer { get; set; }
52: /// <summary/>
53: public string Label { get; set; }
54: /// <summary/>
55: public DateTime Created { get; set; }
56: /// <summary/>
57: public DateTime Updated { get; set; }
58: /// <summary/>
59: public System.Guid UserId { get; set; }
60: /// <summary/>
61: public virtual Ont Ont { get; set; }
62:
63: ////////////////////////////////////////////////////////////////////////////
64:
65: /// <summary>
66: ///
67: /// </summary>
68: [NotMapped]
69: public string State
70: {
71: get
72: {
73: return Ia.Ngn.Cl.Model.Data.Nokia.Ams.BellcoreStateFromId(this.StateId);
74: }
75: }
76:
77: ////////////////////////////////////////////////////////////////////////////
78:
79: /// <summary>
80: ///
81: /// </summary>
82: public static bool Create(OntServiceVoip ontServiceVoip, out string result)
83: {
84: bool b;
85:
86: b = false;
87: result = string.Empty;
88:
89: using (var db = new Ia.Ngn.Cl.Model.Ngn())
90: {
91: ontServiceVoip.Created = ontServiceVoip.Updated = DateTime.UtcNow.AddHours(3);
92:
93: db.OntServiceVoips.Add(ontServiceVoip);
94: db.SaveChanges();
95:
96: b = true;
97: }
98:
99: return b;
100: }
101:
102: ////////////////////////////////////////////////////////////////////////////
103:
104: /// <summary>
105: ///
106: /// </summary>
107: public static OntServiceVoip Read(string id)
108: {
109: OntServiceVoip ontServiceVoip;
110:
111: using (var db = new Ia.Ngn.Cl.Model.Ngn())
112: {
113: ontServiceVoip = (from osv in db.OntServiceVoips where osv.Id == id select osv).SingleOrDefault();
114: }
115:
116: return ontServiceVoip;
117: }
118:
119: ////////////////////////////////////////////////////////////////////////////
120:
121: /// <summary>
122: ///
123: /// </summary>
124: public static List<OntServiceVoip> ReadList()
125: {
126: List<OntServiceVoip> ontServiceVoipList;
127:
128: using (var db = new Ia.Ngn.Cl.Model.Ngn())
129: {
130: ontServiceVoipList = (from osv in db.OntServiceVoips select osv).ToList();
131: }
132:
133: return ontServiceVoipList;
134: }
135:
136: ////////////////////////////////////////////////////////////////////////////
137:
138: /// <summary>
139: ///
140: /// </summary>
141: public static bool Update(OntServiceVoip ontServiceVoip, out string result)
142: {
143: bool b;
144:
145: b = false;
146: result = string.Empty;
147:
148: using (var db = new Ia.Ngn.Cl.Model.Ngn())
149: {
150: ontServiceVoip = (from osv in db.OntServiceVoips where osv.Id == ontServiceVoip.Id select osv).SingleOrDefault();
151:
152: ontServiceVoip.Updated = DateTime.UtcNow.AddHours(3);
153:
154: db.OntServiceVoips.Attach(ontServiceVoip);
155:
156: db.Entry(ontServiceVoip).State = System.Data.Entity.EntityState.Modified;
157: db.SaveChanges();
158:
159: b = true;
160: }
161:
162: return b;
163: }
164:
165: ////////////////////////////////////////////////////////////////////////////
166:
167: /// <summary>
168: ///
169: /// </summary>
170: public static bool Delete(string id, out string result)
171: {
172: bool b;
173:
174: b = false;
175: result = string.Empty;
176:
177: using (var db = new Ia.Ngn.Cl.Model.Ngn())
178: {
179: var v = (from osv in db.OntServiceVoips where osv.Id == id select osv).FirstOrDefault();
180:
181: db.OntServiceVoips.Remove(v);
182: db.SaveChanges();
183:
184: b = true;
185: }
186:
187: return b;
188: }
189:
190:
191: ////////////////////////////////////////////////////////////////////////////
192:
193: /// <summary>
194: ///
195: /// </summary>
196: public bool Equal(OntServiceVoip b)
197: {
198: // below: this will not check the Id, Created, Updated fields
199: bool areEqual;
200:
201: /*if (this.BatteryBackupAvailable != b.BatteryBackupAvailable) areEqual = false;
202: else*/
203: areEqual = true;
204:
205: return areEqual;
206: }
207:
208: ////////////////////////////////////////////////////////////////////////////
209:
210: /// <summary>
211: ///
212: /// </summary>
213: public bool Update(OntServiceVoip b)
214: {
215: // below: this will not update Id, Created
216: bool updated;
217:
218: updated = false;
219:
220: if (this.ConfiguratinFile != b.ConfiguratinFile) { this.ConfiguratinFile = b.ConfiguratinFile; updated = true; }
221: if (this.Customer != b.Customer) { this.Customer = b.Customer; updated = true; }
222: if (this.FtpIp != b.FtpIp) { this.FtpIp = b.FtpIp; updated = true; }
223: if (this.Ip != b.Ip) { this.Ip = b.Ip; updated = true; }
224: if (this.Label != b.Label) { this.Label = b.Label; updated = true; }
225: if (this.MgcIp != b.MgcIp) { this.MgcIp = b.MgcIp; updated = true; }
226: if (this.MgcSecondaryIp != b.MgcSecondaryIp) { this.MgcSecondaryIp = b.MgcSecondaryIp; updated = true; }
227:
228: if (this.Ont != b.Ont) { this.Ont = b.Ont; updated = true; }
229: if (this.StateId != b.StateId) { this.StateId = b.StateId; updated = true; }
230: if (this.Svlan != b.Svlan) { this.Svlan = b.Svlan; updated = true; }
231: if (this.UserId != b.UserId) { this.UserId = b.UserId; updated = true; }
232:
233: if (updated) this.Updated = DateTime.UtcNow.AddHours(3);
234:
235: return updated;
236: }
237:
238: ////////////////////////////////////////////////////////////////////////////
239: ////////////////////////////////////////////////////////////////////////////
240:
241: /// <summary>
242: ///
243: /// </summary>
244: public string ToSimpleTextString()
245: {
246: return Ia.Ngn.Cl.Model.Data.Nokia.OntServiceVoip.ToSimpleTextString(this);
247: }
248:
249: ////////////////////////////////////////////////////////////////////////////
250: ////////////////////////////////////////////////////////////////////////////
251: }
252:
253: ////////////////////////////////////////////////////////////////////////////
254: ////////////////////////////////////////////////////////////////////////////
255: }