1: using System.Collections.Generic;
2: using System.Linq;
3: using System.Web.Http;
4:
5: namespace Ia.Ngn.Cl.Model.Api.Controller
6: {
7: ////////////////////////////////////////////////////////////////////////////
8:
9: /// <summary publish="true">
10: /// NetworkDesignDocument API Controller class of Next Generation Network'a (NGN's) model.
11: /// </summary>
12: ///
13: /// <remarks>
14: /// Copyright © 2006-2017 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 class NetworkDesignDocumentController : ApiController
27: {
28: ////////////////////////////////////////////////////////////////////////////
29:
30: /// <summary>
31: /// Create an access
32: /// </summary>
33: [HttpGet]
34: [Route("api/data/network-design-document/ont/list/{key}")]
35: public List<Ia.Ngn.Cl.Model.Ui.NetworkDesignDocument.Ont> OntList(string key)
36: {
37: Ia.Cl.Model.Result result;
38: Ia.Ngn.Cl.Model.Ui.NetworkDesignDocument.Ont nddOnt;
39: Ia.Ngn.Cl.Model.Business.Administration.StaffContact staffContact;
40: List<Ia.Ngn.Cl.Model.Ui.NetworkDesignDocument.Ont> nddOntList;
41:
42: result = new Ia.Cl.Model.Result();
43: nddOntList = new List<Ia.Ngn.Cl.Model.Ui.NetworkDesignDocument.Ont>();
44:
45: staffContact = (from s in Ia.Ngn.Cl.Model.Data.Administration.StaffContactList where s.ApiKey == key select s).SingleOrDefault();
46:
47: if (Ia.Ngn.Cl.Model.Business.Authority.StaffContactCanCreateReadUpdateDeleteNetworkDesignDocument(Ia.Ngn.Cl.Model.Business.Authority.PersistentStorageFunction.Read, staffContact))
48: {
49: foreach (var n in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList)
50: {
51: nddOnt = new Ia.Ngn.Cl.Model.Ui.NetworkDesignDocument.Ont()
52: {
53: AccessName = n.Access.Name,
54: Card = n.CardSlot,
55: PrimarySwitch = n.PrimarySwitch,
56: Id = n.Id,
57: ImsFsdb = n.ImsFsdb,
58: ImsService = n.ImsService,
59: Ip = n.Ip,
60: MgcIp = n.MgcIp,
61: MgcSecondaryIp = n.MgcSecondaryIp,
62: MgcSubnetMask = n.MgcSubnetMask,
63: Number = n.Number,
64: PonName = n.Pon.Name,
65: Port = n.Port,
66: Position = n.Position,
67: Rack = n.Rack,
68: Sub = n.Sub
69: };
70:
71: nddOntList.Add(nddOnt);
72: }
73: }
74: else
75: {
76: result.AddError("You are not authorized to modify this value (لست مخولاً بتعديل هذه القيمة). ");
77: }
78:
79: return nddOntList;
80: }
81:
82: ////////////////////////////////////////////////////////////////////////////
83:
84: /// <summary>
85: /// Create an access
86: /// </summary>
87: [HttpGet]
88: [Route("api/data/network-design-document/ont/list/{key}/{oltName}")]
89: public List<Ia.Ngn.Cl.Model.Ui.NetworkDesignDocument.Ont> OntList(string key, string oltName)
90: {
91: Ia.Cl.Model.Result result;
92: Ia.Ngn.Cl.Model.Ui.NetworkDesignDocument.Ont nddOnt;
93: Ia.Ngn.Cl.Model.Business.Administration.StaffContact staffContact;
94: List<Ia.Ngn.Cl.Model.Ui.NetworkDesignDocument.Ont> nddOntList;
95:
96: result = new Ia.Cl.Model.Result();
97: nddOntList = new List<Ia.Ngn.Cl.Model.Ui.NetworkDesignDocument.Ont>();
98:
99: staffContact = (from s in Ia.Ngn.Cl.Model.Data.Administration.StaffContactList where s.ApiKey == key select s).SingleOrDefault();
100:
101: if (Ia.Ngn.Cl.Model.Business.Authority.StaffContactCanCreateReadUpdateDeleteNetworkDesignDocument(Ia.Ngn.Cl.Model.Business.Authority.PersistentStorageFunction.Read, staffContact))
102: {
103: if (!string.IsNullOrEmpty(oltName))
104: {
105: oltName = oltName.ToUpper();
106:
107: foreach (var n in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList.Where(u => u.Pon.PonGroup.Olt.Name == oltName))
108: {
109: nddOnt = new Ia.Ngn.Cl.Model.Ui.NetworkDesignDocument.Ont()
110: {
111: AccessName = n.Access.Name,
112: Card = n.CardSlot,
113: PrimarySwitch = n.PrimarySwitch,
114: Id = n.Id,
115: ImsFsdb = n.ImsFsdb,
116: ImsService = n.ImsService,
117: Ip = n.Ip,
118: MgcIp = n.MgcIp,
119: MgcSecondaryIp = n.MgcSecondaryIp,
120: MgcSubnetMask = n.MgcSubnetMask,
121: Number = n.Number,
122: PonName = n.Pon.Name,
123: Port = n.Port,
124: Position = n.Position,
125: Rack = n.Rack,
126: Sub = n.Sub
127: };
128:
129: nddOntList.Add(nddOnt);
130: }
131: }
132: }
133: else
134: {
135: result.AddError("You are not authorized to modify this value (لست مخولاً بتعديل هذه القيمة). ");
136: }
137:
138: return nddOntList;
139: }
140:
141: ////////////////////////////////////////////////////////////////////////////
142: ////////////////////////////////////////////////////////////////////////////
143: }
144: }