1: using System;
2: using System.Collections.Generic;
3: using System.Linq;
4:
5: namespace Ia.Ngn.Cl.Model.Data
6: {
7: ////////////////////////////////////////////////////////////////////////////
8:
9: /// <summary publish="true">
10: /// ServiceExemption Framework class for Next Generation Network (NGN) data model.
11: /// </summary>
12: ///
13: /// <remarks>
14: /// Copyright © 2006-2020 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
15: ///
16: /// 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
17: /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
18: ///
19: /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
20: /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
21: ///
22: /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
23: ///
24: /// Copyright notice: This notice may not be removed or altered from any source distribution.
25: /// </remarks>
26: public partial class ServiceExemption
27: {
28: /// <summary/>
29: public ServiceExemption() { }
30:
31: ////////////////////////////////////////////////////////////////////////////
32:
33: /// <summary>
34: ///
35: /// </summary>
36: public static string Create(Ia.Ngn.Cl.Model.ServiceExemption serviceExemption, out string result)
37: {
38: string id;
39:
40: id = string.Empty;
41: result = string.Empty;
42:
43: using (var db = new Ia.Ngn.Cl.Model.Ngn())
44: {
45: serviceExemption.Created = serviceExemption.Updated = DateTime.UtcNow.AddHours(3);
46:
47: db.ServiceExemptions.Add(serviceExemption);
48: db.SaveChanges();
49:
50: id = serviceExemption.Service;
51: }
52:
53: return id;
54: }
55:
56: ////////////////////////////////////////////////////////////////////////////
57:
58: /// <summary>
59: ///
60: /// </summary>
61: public static Ia.Ngn.Cl.Model.ServiceExemption Read(string id)
62: {
63: Ia.Ngn.Cl.Model.ServiceExemption serviceExemption;
64:
65: using (var db = new Ia.Ngn.Cl.Model.Ngn())
66: {
67: serviceExemption = (from s in db.ServiceExemptions where s.Id == id select s).SingleOrDefault();
68: }
69:
70: return serviceExemption;
71: }
72:
73: ////////////////////////////////////////////////////////////////////////////
74:
75: /// <summary>
76: ///
77: /// </summary>
78: public static List<Ia.Ngn.Cl.Model.ServiceExemption> List()
79: {
80: List<Ia.Ngn.Cl.Model.ServiceExemption> list;
81:
82: using (var db = new Ia.Ngn.Cl.Model.Ngn())
83: {
84: list = (from s in db.ServiceExemptions select s).ToList();
85: }
86:
87: return list;
88: }
89:
90: ////////////////////////////////////////////////////////////////////////////
91:
92: /// <summary>
93: ///
94: /// </summary>
95: public static List<string> ServiceIdList()
96: {
97: List<string> list;
98:
99: using (var db = new Ia.Ngn.Cl.Model.Ngn())
100: {
101: list = (from s in db.ServiceExemptions select s.Id).ToList();
102: }
103:
104: return list;
105: }
106:
107: ////////////////////////////////////////////////////////////////////////////
108:
109: /// <summary>
110: ///
111: /// </summary>
112: public static List<string> ServiceList()
113: {
114: List<string> list;
115:
116: using (var db = new Ia.Ngn.Cl.Model.Ngn())
117: {
118: list = (from s in db.ServiceExemptions select s.Service).ToList();
119: }
120:
121: return list;
122: }
123:
124: ////////////////////////////////////////////////////////////////////////////
125:
126: /// <summary>
127: ///
128: /// </summary>
129: public static bool Update(Ia.Ngn.Cl.Model.ServiceExemption updatedServiceExemption, out string result)
130: {
131: bool b;
132: Ia.Ngn.Cl.Model.ServiceExemption serviceExemption;
133:
134: b = false;
135: result = string.Empty;
136:
137: using (var db = new Ia.Ngn.Cl.Model.Ngn())
138: {
139: serviceExemption = (from se in db.ServiceExemptions where se.Id == updatedServiceExemption.Id select se).SingleOrDefault();
140:
141: if (serviceExemption.Update(updatedServiceExemption))
142: {
143: db.ServiceExemptions.Attach(serviceExemption);
144: db.Entry(serviceExemption).State = System.Data.Entity.EntityState.Modified;
145: }
146:
147: db.SaveChanges();
148:
149: b = true;
150: }
151:
152: return b;
153: }
154:
155: ////////////////////////////////////////////////////////////////////////////
156:
157: /// <summary>
158: ///
159: /// </summary>
160: public static bool Delete(string id)
161: {
162: bool b;
163:
164: b = false;
165:
166: using (var db = new Ia.Ngn.Cl.Model.Ngn())
167: {
168: var v = (from s in db.ServiceExemptions where s.Id == id select s).FirstOrDefault();
169:
170: db.ServiceExemptions.Remove(v);
171: db.SaveChanges();
172:
173: b = true;
174: }
175:
176: return b;
177: }
178:
179: ////////////////////////////////////////////////////////////////////////////
180: ////////////////////////////////////////////////////////////////////////////
181: }
182:
183: ////////////////////////////////////////////////////////////////////////////
184: ////////////////////////////////////////////////////////////////////////////
185: }