شركة التطبيقات المتكاملة لتصميم النظم البرمجية الخاصة

Integrated Applications Programming Company

Skip Navigation LinksHome » Code Library » Service2

Public general use code classes and xml files that we've compiled and used over the years:

Service support class for Next Generation Network (NGN) data model.

   1:  using System.Collections;
   2:  using System.Collections.Generic;
   3:  using System.Linq;
   4:  using System.Data;
   5:  using System.Data.Entity;
   6:  using System;
   7:   
   8:  namespace Ia.Ngn.Cl.Model.Data
   9:  {
  10:      ////////////////////////////////////////////////////////////////////////////
  11:   
  12:      /// <summary publish="true">
  13:      /// Service support class for Next Generation Network (NGN) data model.
  14:      /// </summary>
  15:      /// 
  16:      /// <remarks> 
  17:      /// Copyright © 2006-2019 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet Applications - Kuwait. All Rights Reserved.
  18:      ///
  19:      /// 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
  20:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  21:      ///
  22:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  23:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  24:      /// 
  25:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  26:      /// 
  27:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  28:      /// </remarks> 
  29:      public partial class Service2
  30:      {
  31:          public Service2() { }
  32:   
  33:          ////////////////////////////////////////////////////////////////////////////
  34:   
  35:          /// <summary>
  36:          /// Read service
  37:          /// </summary>
  38:          public static Ia.Ngn.Cl.Model.Service2 Read(string service)
  39:          {
  40:              Ia.Ngn.Cl.Model.Service2 service2;
  41:   
  42:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
  43:              {
  44:                  service2 = (from s in db.Service2s
  45:                              where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.NgnService && s.Service == service
  46:                              select s).SingleOrDefault();
  47:              }
  48:   
  49:              return service2;
  50:          }
  51:   
  52:          ////////////////////////////////////////////////////////////////////////////
  53:   
  54:          /// <summary>
  55:          /// Read PSTN service
  56:          /// </summary>
  57:          public static Ia.Ngn.Cl.Model.Service2 ReadPstn(string service)
  58:          {
  59:              Ia.Ngn.Cl.Model.Service2 service2;
  60:   
  61:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
  62:              {
  63:                  service2 = (from s in db.Service2s
  64:                              where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.PstnService && s.Service == service
  65:                              select s).SingleOrDefault();
  66:              }
  67:   
  68:              return service2;
  69:          }
  70:   
  71:          ////////////////////////////////////////////////////////////////////////////
  72:   
  73:          /// <summary>
  74:          /// Read service of a number
  75:          /// </summary>
  76:          public static Ia.Ngn.Cl.Model.Service2 Read(long number)
  77:          {
  78:              Ia.Ngn.Cl.Model.Service2 service;
  79:   
  80:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
  81:              {
  82:                  service = (from s in db.Service2s
  83:                             where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.NgnService && s.Service == number.ToString()
  84:                             select s).SingleOrDefault();
  85:              }
  86:   
  87:              return service;
  88:          }
  89:   
  90:          ////////////////////////////////////////////////////////////////////////////
  91:   
  92:          /// <summary>
  93:          /// Read service from Id
  94:          /// </summary>
  95:          public static Ia.Ngn.Cl.Model.Service2 ReadByIdIncludeAccess(string serviceId)
  96:          {
  97:              Ia.Ngn.Cl.Model.Service2 service2;
  98:   
  99:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 100:              {
 101:                  service2 = (from s in db.Service2s.Include(a => a.Access)
 102:                              where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.NgnService && s.Id == serviceId
 103:                              select s).SingleOrDefault();
 104:              }
 105:   
 106:              return service2;
 107:          }
 108:   
 109:          ////////////////////////////////////////////////////////////////////////////
 110:   
 111:          /// <summary>
 112:          /// Read service of a number
 113:          /// </summary>
 114:          public static Ia.Ngn.Cl.Model.Service2 ReadWithAccess(string service)
 115:          {
 116:              Ia.Ngn.Cl.Model.Service2 service2;
 117:   
 118:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 119:              {
 120:                  service2 = (from s in db.Service2s.Include(a => a.Access)
 121:                              where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.NgnService && s.Service == service
 122:                              select s).SingleOrDefault();
 123:              }
 124:   
 125:              return service2;
 126:          }
 127:   
 128:          ////////////////////////////////////////////////////////////////////////////
 129:   
 130:          /// <summary>
 131:          ///
 132:          /// </summary>
 133:          public static List<Ia.Ngn.Cl.Model.Service2> List()
 134:          {
 135:              List<Ia.Ngn.Cl.Model.Service2> serviceList;
 136:   
 137:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 138:              {
 139:                  serviceList = (from s in db.Service2s where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.NgnService select s).ToList();
 140:              }
 141:   
 142:              return serviceList;
 143:          }
 144:   
 145:          ////////////////////////////////////////////////////////////////////////////
 146:   
 147:          /// <summary>
 148:          ///
 149:          /// </summary>
 150:          public static List<string> List(List<int> domainList)
 151:          {
 152:              List<string> stringDomainList;
 153:              List<string> serviceList;
 154:   
 155:              stringDomainList = new List<string>();
 156:   
 157:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 158:              {
 159:                  if (domainList != null)
 160:                  {
 161:                      foreach (int i in domainList) stringDomainList.Add(i.ToString());
 162:   
 163:                      serviceList = (from s in db.Service2s
 164:                                     where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.NgnService && stringDomainList.Any(u => s.Service.StartsWith(u.ToString()))
 165:                                     select s.Service).ToList();
 166:                  }
 167:                  else
 168:                  {
 169:                      serviceList = (from s in db.Service2s where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.NgnService select s.Service).ToList();
 170:                  }
 171:              }
 172:   
 173:              return serviceList;
 174:          }
 175:   
 176:          ////////////////////////////////////////////////////////////////////////////
 177:   
 178:          /// <summary>
 179:          ///
 180:          /// </summary>
 181:          public static List<string> ServiceList
 182:          {
 183:              get
 184:              {
 185:                  List<string> list;
 186:   
 187:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 188:                  {
 189:                      list = (from s in db.Service2s where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.NgnService select s.Service).ToList();
 190:                  }
 191:   
 192:                  return list;
 193:              }
 194:          }
 195:   
 196:          ////////////////////////////////////////////////////////////////////////////
 197:   
 198:          /// <summary>
 199:          /// 
 200:          /// </summary>
 201:          public static List<string> NgnAndPstnServiceIdList
 202:          {
 203:              get
 204:              {
 205:                  List<string> list;
 206:   
 207:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 208:                  {
 209:                      list = (from s in db.Service2s select s.Id).ToList();
 210:                  }
 211:   
 212:                  return list.ToList();
 213:              }
 214:          }
 215:   
 216:          ////////////////////////////////////////////////////////////////////////////
 217:   
 218:          /// <summary>
 219:          /// 
 220:          /// </summary>
 221:          public static List<string> ServiceIdList
 222:          {
 223:              get
 224:              {
 225:                  List<string> list;
 226:   
 227:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 228:                  {
 229:                      list = (from s in db.Service2s where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.NgnService select s.Id).ToList();
 230:                  }
 231:   
 232:                  return list.ToList();
 233:              }
 234:          }
 235:   
 236:          ////////////////////////////////////////////////////////////////////////////
 237:   
 238:          /// <summary>
 239:          /// 
 240:          /// </summary>
 241:          public static Dictionary<string, DateTime> ServiceIdToCreatedDateTimeDictionary
 242:          {
 243:              get
 244:              {
 245:                  Dictionary<string, DateTime> dictionary;
 246:   
 247:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 248:                  {
 249:                      dictionary = (from s in db.Service2s
 250:                                    where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.NgnService
 251:                                    select new { s.Id, s.Created }).ToDictionary(m => m.Id, m => m.Created);
 252:                  }
 253:   
 254:                  return dictionary;
 255:              }
 256:          }
 257:   
 258:          ////////////////////////////////////////////////////////////////////////////
 259:   
 260:          /// <summary>
 261:          /// 
 262:          /// </summary>
 263:          public static List<Ia.Ngn.Cl.Model.Service2> PstnServiceList
 264:          {
 265:              get
 266:              {
 267:                  List<Ia.Ngn.Cl.Model.Service2> list;
 268:   
 269:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 270:                  {
 271:                      list = (from s in db.Service2s where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.PstnService select s).Include(s => s.Access).ToList();
 272:                  }
 273:   
 274:                  return list.ToList();
 275:              }
 276:          }
 277:   
 278:          ////////////////////////////////////////////////////////////////////////////
 279:   
 280:          /// <summary>
 281:          /// Read all services for a number list
 282:          /// </summary>
 283:          public static List<Ia.Ngn.Cl.Model.Service2> ReadList(ArrayList numberList)
 284:          {
 285:              long i;
 286:              long[] sp;
 287:              List<Ia.Ngn.Cl.Model.Service2> serviceList;
 288:   
 289:              i = 0;
 290:              sp = new long[numberList.Count];
 291:   
 292:              foreach (long l in numberList) sp[i++] = l;
 293:   
 294:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 295:              {
 296:                  //serviceList = (from q in db.Services where dnList.Contains(q.DN) select q).ToList();
 297:   
 298:                  // var pages = context.Pages.Where(x => keys.Any(key => x.Title.Contains(key)));
 299:                  serviceList = db.Service2s.Where(s => s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.NgnService && sp.Any(v => s.Service == v.ToString())).ToList();
 300:              }
 301:   
 302:              return serviceList;
 303:          }
 304:   
 305:          ////////////////////////////////////////////////////////////////////////////
 306:   
 307:          /// <summary>
 308:          /// 
 309:          /// </summary>
 310:          public static Dictionary<string, int> ServiceIdToPortDictionary
 311:          {
 312:              get
 313:              {
 314:                  Dictionary<string, int> dictionary;
 315:   
 316:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 317:                  {
 318:                      dictionary = (from s in db.Service2s
 319:                                    where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.NgnService && s.Access != null
 320:                                    select new { s.Id, s.Port }).ToDictionary(m => m.Id, m => m.Port);
 321:                  }
 322:   
 323:                  return dictionary;
 324:              }
 325:          }
 326:   
 327:          ////////////////////////////////////////////////////////////////////////////
 328:   
 329:          /// <summary>
 330:          ///
 331:          /// </summary>
 332:          public static Ia.Ngn.Cl.Model.Access ReadAccess(string id)
 333:          {
 334:              Ia.Ngn.Cl.Model.Access access;
 335:   
 336:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 337:              {
 338:                  access = (from s in db.Service2s
 339:                            where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.NgnService && s.Id == id
 340:                            select s.Access).SingleOrDefault();
 341:              }
 342:   
 343:              return access;
 344:          }
 345:   
 346:          ////////////////////////////////////////////////////////////////////////////
 347:   
 348:          /// <summary>
 349:          ///
 350:          /// </summary>
 351:          public static Dictionary<string, int> ServicePortDictionary
 352:          {
 353:              get
 354:              {
 355:                  Dictionary<string, int> dictionary;
 356:   
 357:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 358:                  {
 359:                      dictionary = (from s in db.Service2s
 360:                                    where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.NgnService && s.Port > -1
 361:                                    select new { s.Service, s.Port }).ToDictionary(m => m.Service, m => m.Port);
 362:                  }
 363:   
 364:                  return dictionary;
 365:              }
 366:          }
 367:   
 368:          ////////////////////////////////////////////////////////////////////////////
 369:   
 370:          /// <summary>
 371:          ///
 372:          /// </summary>
 373:          public static Ia.Ngn.Cl.Model.Access ReadAccess(Ia.Ngn.Cl.Model.Ngn db, string id)
 374:          {
 375:              Ia.Ngn.Cl.Model.Access access;
 376:   
 377:              access = (from s in db.Service2s
 378:                        where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.NgnService && s.Id == id
 379:                        select s.Access).SingleOrDefault();
 380:   
 381:              return access;
 382:          }
 383:   
 384:          ////////////////////////////////////////////////////////////////////////////
 385:   
 386:          /// <summary>
 387:          ///
 388:          /// </summary>
 389:          public static bool UpdatePort(Ia.Ngn.Cl.Model.Service2 service, int port, out string result)
 390:          {
 391:              bool b;
 392:   
 393:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 394:              {
 395:                  service = (from s in db.Service2s
 396:                             where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.NgnService && s.Id == service.Id
 397:                             select s).SingleOrDefault();
 398:   
 399:                  if (service.Port != port)
 400:                  {
 401:                      service.Port = port;
 402:   
 403:                      db.Service2s.Attach(service);
 404:                      db.Entry(service).Property(x => x.Port).IsModified = true;
 405:   
 406:                      db.SaveChanges();
 407:   
 408:                      result = "Success: Service Port updated. ";
 409:                      b = true;
 410:                  }
 411:                  else
 412:                  {
 413:                      result = "Warning: Service Port value was not updated because its the same. ";
 414:   
 415:                      b = false;
 416:                  }
 417:              }
 418:   
 419:              return b;
 420:          }
 421:   
 422:          ////////////////////////////////////////////////////////////////////////////
 423:   
 424:          /// <summary>
 425:          ///
 426:          /// </summary>
 427:          public static List<Ia.Ngn.Cl.Model.Service2> ServiceWithNullAccessList
 428:          {
 429:              get
 430:              {
 431:                  List<Ia.Ngn.Cl.Model.Service2> serviceList;
 432:   
 433:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 434:                  {
 435:                      serviceList = (from s in db.Service2s
 436:                                     where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.NgnService && s.Access == null
 437:                                     select s).ToList();
 438:                  }
 439:   
 440:                  return serviceList;
 441:              }
 442:          }
 443:   
 444:          ////////////////////////////////////////////////////////////////////////////
 445:   
 446:          /// <summary>
 447:          /// Services within a SIP designated OLT
 448:          /// </summary>
 449:          public static List<string> ServiceIdWithinSipOltList()
 450:          {
 451:              List<int> sipOltIdList;
 452:              List<string> list, list2;
 453:   
 454:              sipOltIdList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SipOltIdList;
 455:   
 456:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 457:              {
 458:                  // services with access
 459:                  list = (from s in db.Service2s
 460:                          where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.NgnService && s.Access != null && sipOltIdList.Contains(s.Access.Olt)
 461:                          select s.Id).ToList();
 462:   
 463:                  // services without access might be newly installed
 464:                  list2 = (from s in db.Service2s
 465:                           join srs in db.ServiceRequestServices on s.Service equals srs.Service
 466:                           where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.NgnService && s.Access == null && srs.Access != null && srs.Provisioned == true && sipOltIdList.Contains(srs.Access.Olt)
 467:                           select s.Id).ToList();
 468:              }
 469:   
 470:              return list.Union(list2).Distinct().ToList();
 471:          }
 472:   
 473:          ////////////////////////////////////////////////////////////////////////////
 474:   
 475:          /// <summary>
 476:          /// Services within a SIP allowed to be provisioned or migrated OLT
 477:          /// </summary>
 478:          public static List<string> ServiceIdWithinAllowedSipOltToBeProvisionedOrMigratedList()
 479:          {
 480:              List<int> sipOltIdList;
 481:              List<string> list, list2;
 482:   
 483:              sipOltIdList = Ia.Ngn.Cl.Model.Data.Service.AllowedToBeProvisionedSipOltIdList.Union(Ia.Ngn.Cl.Model.Data.Service.AllowedToBeMigratedSipOltIdList).ToList();
 484:   
 485:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 486:              {
 487:                  // services with access
 488:                  list = (from s in db.Service2s where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.NgnService && s.Access != null && sipOltIdList.Contains(s.Access.Olt) select s.Id).ToList();
 489:   
 490:                  // services without access might be newly installed
 491:                  list2 = (from s in db.Service2s
 492:                           join srs in db.ServiceRequestServices on s.Service equals srs.Service
 493:                           where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.NgnService && s.Access == null && srs.Access != null && srs.Provisioned == true && sipOltIdList.Contains(srs.Access.Olt)
 494:                           select s.Id).ToList();
 495:              }
 496:   
 497:              return list.Union(list2).Distinct().ToList();
 498:          }
 499:   
 500:          ////////////////////////////////////////////////////////////////////////////
 501:   
 502:          /// <summary>
 503:          /// Services within a SIP allowed to be provisioned or migrated OLT
 504:          /// </summary>
 505:          public static Dictionary<string, DateTime> ServiceIdWithinAllowedSipOltToBeProvisionedOrMigratedToCreatedDateTimeDictionary
 506:          {
 507:              get
 508:              {
 509:                  List<int> sipOltIdList;
 510:                  Dictionary<string, DateTime> dictionary, dictionary2;
 511:   
 512:                  sipOltIdList = Ia.Ngn.Cl.Model.Data.Service.AllowedToBeProvisionedSipOltIdList.Union(Ia.Ngn.Cl.Model.Data.Service.AllowedToBeMigratedSipOltIdList).ToList();
 513:   
 514:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 515:                  {
 516:                      // services with access
 517:                      dictionary = (from s in db.Service2s
 518:                                    where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.NgnService && s.Access != null && sipOltIdList.Contains(s.Access.Olt)
 519:                                    select new { s.Id, s.Created }).ToDictionary(m => m.Id, m => m.Created);
 520:   
 521:                      // services without access might be newly installed
 522:                      dictionary2 = (from s in db.Service2s
 523:                                     join srs in db.ServiceRequestServices on s.Service equals srs.Service
 524:                                     where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.NgnService && s.Access == null && srs.Access != null && srs.Provisioned == true && sipOltIdList.Contains(srs.Access.Olt)
 525:                                     select new { s.Id, s.Created }).ToDictionary(m => m.Id, m => m.Created);
 526:                  }
 527:   
 528:                  return dictionary.Union(dictionary2).ToDictionary(m => m.Key, m => m.Value);
 529:              }
 530:          }
 531:   
 532:          ////////////////////////////////////////////////////////////////////////////
 533:   
 534:          /// <summary>
 535:          /// Services within Huawei switch domain list
 536:          /// </summary>
 537:          public static List<string> ServiceIdWithinHuaweiSwitchDomainList()
 538:          {
 539:              List<int> huaweiSwitchDomainList;
 540:              List<string> list;
 541:   
 542:              huaweiSwitchDomainList = Ia.Ngn.Cl.Model.Data.Service.HuaweiSwitchDomainList;
 543:   
 544:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 545:              {
 546:                  list = (from s in db.Service2s
 547:                          where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.NgnService && huaweiSwitchDomainList.Any(u => s.Service.StartsWith(u.ToString()))
 548:                          select s.Id).ToList();
 549:              }
 550:   
 551:              return list.ToList();
 552:          }
 553:   
 554:          ////////////////////////////////////////////////////////////////////////////
 555:   
 556:          /// <summary>
 557:          /// Services within Nokia switch domain list
 558:          /// </summary>
 559:          public static List<string> ServiceIdWithinNokiaSwitchDomainList()
 560:          {
 561:              List<int> nokiaSwitchDomainList;
 562:              List<string> list;
 563:   
 564:              nokiaSwitchDomainList = Ia.Ngn.Cl.Model.Data.Service.NokiaSwitchDomainList;
 565:   
 566:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 567:              {
 568:                  list = (from s in db.Service2s
 569:                          where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.NgnService && nokiaSwitchDomainList.Any(u => s.Service.StartsWith(u.ToString()))
 570:                          select s.Id).ToList();
 571:              }
 572:   
 573:              return list.ToList();
 574:          }
 575:   
 576:          ////////////////////////////////////////////////////////////////////////////
 577:   
 578:          /// <summary>
 579:          ///
 580:          /// </summary>
 581:          public static List<string> ServiceIdWithNullAccessList()
 582:          {
 583:              List<string> list;
 584:   
 585:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 586:              {
 587:                  list = (from s in db.Service2s
 588:                          where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.NgnService && s.Access == null
 589:                          select s.Id).ToList();
 590:              }
 591:   
 592:              return list;
 593:          }
 594:   
 595:          ////////////////////////////////////////////////////////////////////////////
 596:   
 597:          /// <summary>
 598:          ///
 599:          /// </summary>
 600:          public static List<Ia.Ngn.Cl.Model.Service2> ServiceSuspensionIsTrueList
 601:          {
 602:              get
 603:              {
 604:                  List<Ia.Ngn.Cl.Model.Service2> serviceList;
 605:   
 606:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 607:                  {
 608:                      serviceList = (from s in db.Service2s
 609:                                     where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.NgnService && s.ServiceSuspension == true
 610:                                     select s).ToList();
 611:                  }
 612:   
 613:                  return serviceList;
 614:              }
 615:          }
 616:   
 617:          ////////////////////////////////////////////////////////////////////////////
 618:   
 619:          /// <summary>
 620:          ///
 621:          /// </summary>
 622:          public static int ServiceSuspensionIsTrueListCount
 623:          {
 624:              get
 625:              {
 626:                  int c;
 627:   
 628:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 629:                  {
 630:                      c = (from s in db.Service2s
 631:                           where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.NgnService && s.ServiceSuspension == true
 632:                           select s).Count();
 633:                  }
 634:   
 635:                  return c;
 636:              }
 637:          }
 638:   
 639:          ////////////////////////////////////////////////////////////////////////////
 640:   
 641:          /// <summary>
 642:          ///
 643:          /// </summary>
 644:          public static List<Ia.Ngn.Cl.Model.Service2> ServiceSuspensionIsFalseList
 645:          {
 646:              get
 647:              {
 648:                  List<Ia.Ngn.Cl.Model.Service2> serviceList;
 649:   
 650:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 651:                  {
 652:                      serviceList = (from s in db.Service2s
 653:                                     where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.NgnService && s.ServiceSuspension == false
 654:                                     select s).ToList();
 655:                  }
 656:   
 657:                  return serviceList;
 658:              }
 659:          }
 660:   
 661:          ////////////////////////////////////////////////////////////////////////////
 662:   
 663:          /// <summary>
 664:          ///
 665:          /// </summary>
 666:          public static List<string> ServiceSuspensionIsTrueStringNumberList
 667:          {
 668:              get
 669:              {
 670:                  List<string> serviceNumberStringList;
 671:                  List<Ia.Ngn.Cl.Model.Service2> serviceList;
 672:   
 673:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 674:                  {
 675:                      // below:                
 676:                      serviceList = ServiceSuspensionIsTrueList;
 677:   
 678:                      if (serviceList.Count > 0)
 679:                      {
 680:                          serviceNumberStringList = new List<string>(serviceList.Count);
 681:   
 682:                          foreach (Ia.Ngn.Cl.Model.Service2 srs in serviceList)
 683:                          {
 684:                              serviceNumberStringList.Add(srs.Service);
 685:                          }
 686:                      }
 687:                      else
 688:                      {
 689:                          // below: not null
 690:                          serviceNumberStringList = new List<string>(1);
 691:                      }
 692:                  }
 693:   
 694:                  return serviceNumberStringList;
 695:              }
 696:          }
 697:   
 698:          ////////////////////////////////////////////////////////////////////////////
 699:   
 700:          /// <summary>
 701:          ///
 702:          /// </summary>
 703:          public static List<string> ServiceSuspensionIsFalseStringNumberList
 704:          {
 705:              get
 706:              {
 707:                  List<string> serviceNumberStringList;
 708:                  List<Ia.Ngn.Cl.Model.Service2> serviceList;
 709:   
 710:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 711:                  {
 712:                      // below:                
 713:                      serviceList = ServiceSuspensionIsFalseList;
 714:   
 715:                      if (serviceList.Count > 0)
 716:                      {
 717:                          serviceNumberStringList = new List<string>(serviceList.Count);
 718:   
 719:                          foreach (Ia.Ngn.Cl.Model.Service2 srs in serviceList)
 720:                          {
 721:                              serviceNumberStringList.Add(srs.Service);
 722:                          }
 723:                      }
 724:                      else
 725:                      {
 726:                          // below: not null
 727:                          serviceNumberStringList = new List<string>(1);
 728:                      }
 729:                  }
 730:   
 731:                  return serviceNumberStringList;
 732:              }
 733:          }
 734:   
 735:          ////////////////////////////////////////////////////////////////////////////
 736:   
 737:          /// <summary>
 738:          ///
 739:          /// </summary>
 740:          public static Dictionary<string, string> ServiceIdToAccessIdDictionary
 741:          {
 742:              get
 743:              {
 744:                  Dictionary<string, string> dictionary, nullAccessDictionary;
 745:   
 746:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 747:                  {
 748:                      dictionary = (from s in db.Service2s
 749:                                    where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.NgnService && s.Access != null
 750:                                    select new { s.Id, s.Access }).ToDictionary(u => u.Id, u => u.Access.Id);
 751:   
 752:                      nullAccessDictionary = (from s in db.Service2s
 753:                                              where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.NgnService && s.Access == null
 754:                                              select new { s.Id, s.Access }).ToDictionary(u => u.Id, u => string.Empty);
 755:                  }
 756:   
 757:                  return dictionary.Union(nullAccessDictionary).ToDictionary(u => u.Key, u => u.Value);
 758:              }
 759:          }
 760:   
 761:          ////////////////////////////////////////////////////////////////////////////
 762:   
 763:          /// <summary>
 764:          ///
 765:          /// </summary>
 766:          public static Dictionary<string, string> PstnServiceIdToAccessIdDictionary
 767:          {
 768:              get
 769:              {
 770:                  Dictionary<string, string> dictionary, nullAccessDictionary;
 771:   
 772:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 773:                  {
 774:                      dictionary = (from s in db.Service2s
 775:                                    where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.PstnService && s.Access != null
 776:                                    select new { s.Id, s.Access }).ToDictionary(u => u.Id, u => u.Access.Id);
 777:   
 778:                      nullAccessDictionary = (from s in db.Service2s
 779:                                              where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.PstnService && s.Access == null
 780:                                              select new { s.Id, s.Access }).ToDictionary(u => u.Id, u => string.Empty);
 781:                  }
 782:   
 783:                  return dictionary.Union(nullAccessDictionary).ToDictionary(u => u.Key, u => u.Value);
 784:              }
 785:          }
 786:   
 787:          ////////////////////////////////////////////////////////////////////////////
 788:   
 789:          /// <summary>
 790:          ///
 791:          /// </summary>
 792:          public static Dictionary<string, string> MigratedServiceIdToAccessIdDictionary
 793:          {
 794:              get
 795:              {
 796:                  Dictionary<string, string> dictionary, nullAccessDictionary;
 797:   
 798:                  var migrationDomainList = Ia.Ngn.Cl.Model.Data.Service.MigrationDomainList;
 799:                  var migrationDomainStringList = migrationDomainList.ConvertAll<string>(delegate (int i) { return i.ToString(); });
 800:   
 801:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 802:                  {
 803:                      dictionary = (from s in db.Service2s
 804:                                    where s.Access != null && migrationDomainStringList.Any(u => s.Service.StartsWith(u))
 805:                                    select new { s.Id, s.Access }).ToDictionary(u => u.Id, u => u.Access.Id);
 806:   
 807:                      nullAccessDictionary = (from s in db.Service2s
 808:                                              where s.Access == null && migrationDomainStringList.Any(u => s.Service.StartsWith(u))
 809:                                              select new { s.Id, s.Access }).ToDictionary(u => u.Id, u => string.Empty);
 810:                  }
 811:   
 812:                  return dictionary.Union(nullAccessDictionary).ToDictionary(u => u.Key, u => u.Value);
 813:              }
 814:          }
 815:   
 816:          ////////////////////////////////////////////////////////////////////////////
 817:   
 818:          /// <summary>
 819:          ///
 820:          /// </summary>
 821:          public static Dictionary<string, string> MigratedServiceIdToAccessIdInAllowedToBeMigratedOltDictionary
 822:          {
 823:              get
 824:              {
 825:                  Dictionary<string, string> dictionary;
 826:   
 827:                  var allowedToBeMigratedOltIdList = Ia.Ngn.Cl.Model.Data.Service.AllowedToBeMigratedOltIdList;
 828:   
 829:                  var migrationDomainList = Ia.Ngn.Cl.Model.Data.Service.MigrationDomainList;
 830:                  var migrationDomainStringList = migrationDomainList.ConvertAll<string>(delegate (int i) { return i.ToString(); });
 831:   
 832:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 833:                  {
 834:                      dictionary = (from s in db.Service2s
 835:                                    where s.Access != null && migrationDomainStringList.Any(u => s.Service.StartsWith(u)) && allowedToBeMigratedOltIdList.Contains(s.Access.Olt) && s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.NgnService
 836:                                    select new { s.Id, s.Access }).ToDictionary(u => u.Id, u => u.Access.Id);
 837:                  }
 838:   
 839:                  return dictionary.ToDictionary(u => u.Key, u => u.Value);
 840:              }
 841:          }
 842:   
 843:          ////////////////////////////////////////////////////////////////////////////
 844:   
 845:          /// <summary>
 846:          ///
 847:          /// </summary>
 848:          public static Dictionary<string, string> ServiceToAccessIdInAllowedToBeMigratedOltDictionary
 849:          {
 850:              get
 851:              {
 852:                  Dictionary<string, string> dictionary;
 853:   
 854:                  var allowedToBeMigratedOltIdList = Ia.Ngn.Cl.Model.Data.Service.AllowedToBeMigratedOltIdList;
 855:   
 856:                  var migrationDomainList = Ia.Ngn.Cl.Model.Data.Service.MigrationDomainList;
 857:                  var migrationDomainStringList = migrationDomainList.ConvertAll<string>(delegate (int i) { return i.ToString(); });
 858:   
 859:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 860:                  {
 861:                      dictionary = (from s in db.Service2s
 862:                                    where s.Access != null && migrationDomainStringList.Any(u => s.Service.StartsWith(u)) && allowedToBeMigratedOltIdList.Contains(s.Access.Olt) && s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.NgnService
 863:                                    select new { s.Service, s.Access }).ToDictionary(u => u.Service, u => u.Access.Id);
 864:                  }
 865:   
 866:                  return dictionary.ToDictionary(u => u.Key, u => u.Value);
 867:              }
 868:          }
 869:   
 870:          ////////////////////////////////////////////////////////////////////////////
 871:   
 872:          /// <summary>
 873:          ///
 874:          /// </summary>
 875:          public static Dictionary<string, string> ServiceToAccessIdDictionary
 876:          {
 877:              get
 878:              {
 879:                  string key;
 880:                  Dictionary<string, string> serviceToAccessIdDictionary, serviceIdToAccessIdDictionary;
 881:   
 882:                  serviceIdToAccessIdDictionary = ServiceIdToAccessIdDictionary;
 883:   
 884:                  serviceToAccessIdDictionary = new Dictionary<string, string>(serviceIdToAccessIdDictionary.Count);
 885:   
 886:                  foreach (KeyValuePair<string, string> kvp in serviceIdToAccessIdDictionary)
 887:                  {
 888:                      key = Ia.Ngn.Cl.Model.Business.Service.ServiceIdToService(kvp.Key);
 889:   
 890:                      serviceToAccessIdDictionary[key] = kvp.Value;
 891:                  }
 892:   
 893:                  return serviceToAccessIdDictionary;
 894:              }
 895:          }
 896:   
 897:          ////////////////////////////////////////////////////////////////////////////
 898:   
 899:          /// <summary>
 900:          ///
 901:          /// </summary>
 902:          public static Dictionary<string, string> ServiceIdToAccessNameDictionary
 903:          {
 904:              get
 905:              {
 906:                  Dictionary<string, string> dictionary, nullAccessDictionary;
 907:   
 908:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 909:                  {
 910:                      dictionary = (from s in db.Service2s
 911:                                    where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.NgnService && s.Access != null
 912:                                    select new { s.Id, s.Access }).ToDictionary(u => u.Id, u => u.Access.Name);
 913:   
 914:                      nullAccessDictionary = (from s in db.Service2s
 915:                                              where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.NgnService && s.Access == null
 916:                                              select s.Id).ToDictionary(u => u, null);
 917:                  }
 918:   
 919:                  return dictionary.Union(nullAccessDictionary).ToDictionary(u => u.Key, u => u.Value);
 920:              }
 921:          }
 922:   
 923:          ////////////////////////////////////////////////////////////////////////////
 924:   
 925:          /// <summary>
 926:          ///
 927:          /// </summary>
 928:          public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> ServiceToNddOntDictionary
 929:          {
 930:              get
 931:              {
 932:                  string key;
 933:                  Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> dictionary;
 934:   
 935:                  var serviceIdToAccessIdDictionary = Ia.Ngn.Cl.Model.Data.Service2.ServiceIdToAccessIdDictionary;
 936:                  var ontAccessIdToOntDictionary = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessIdToOntDictionary;
 937:   
 938:                  dictionary = new Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont>(serviceIdToAccessIdDictionary.Count);
 939:   
 940:                  foreach (KeyValuePair<string, string> kvp in serviceIdToAccessIdDictionary)
 941:                  {
 942:                      key = Ia.Ngn.Cl.Model.Business.Service.ServiceIdToService(kvp.Key);
 943:   
 944:                      if (!string.IsNullOrEmpty(kvp.Value)) dictionary[key] = ontAccessIdToOntDictionary[kvp.Value];
 945:                      else dictionary[key] = null;
 946:                  }
 947:   
 948:                  return dictionary;
 949:              }
 950:          }
 951:   
 952:          ////////////////////////////////////////////////////////////////////////////
 953:   
 954:          /// <summary>
 955:          ///
 956:          /// </summary>
 957:          public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> PstnServiceToNddOntDictionary
 958:          {
 959:              get
 960:              {
 961:                  string key;
 962:                  Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> dictionary;
 963:   
 964:                  var pstnServiceIdToAccessIdDictionary = Ia.Ngn.Cl.Model.Data.Service2.PstnServiceIdToAccessIdDictionary;
 965:                  var ontAccessIdToOntDictionary = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessIdToOntDictionary;
 966:   
 967:                  dictionary = new Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont>(pstnServiceIdToAccessIdDictionary.Count);
 968:   
 969:                  foreach (KeyValuePair<string, string> kvp in pstnServiceIdToAccessIdDictionary)
 970:                  {
 971:                      key = Ia.Ngn.Cl.Model.Business.Service.ServiceIdToService(kvp.Key);
 972:   
 973:                      if (!string.IsNullOrEmpty(kvp.Value)) dictionary[key] = ontAccessIdToOntDictionary[kvp.Value];
 974:                      //else dictionary[key] = null;
 975:                  }
 976:   
 977:                  return dictionary;
 978:              }
 979:          }
 980:   
 981:          ////////////////////////////////////////////////////////////////////////////
 982:   
 983:          /// <summary>
 984:          ///
 985:          /// </summary>
 986:          public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor> MigratedServiceToNddOntRouterVendorDictionary
 987:          {
 988:              get
 989:              {
 990:                  string key;
 991:                  Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor> dictionary;
 992:   
 993:                  var migratedServiceIdToAccessIdDictionary = Ia.Ngn.Cl.Model.Data.Service2.MigratedServiceIdToAccessIdDictionary;
 994:                  var ontAccessIdToOntDictionary = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessIdToOntDictionary;
 995:   
 996:                  dictionary = new Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor>(migratedServiceIdToAccessIdDictionary.Count);
 997:   
 998:                  foreach (KeyValuePair<string, string> kvp in migratedServiceIdToAccessIdDictionary)
 999:                  {
1000:                      key = Ia.Ngn.Cl.Model.Business.Service.ServiceIdToService(kvp.Key);
1001:   
1002:                      //if (!string.IsNullOrEmpty(kvp.Value)) dictionary[key] = ontAccessIdToOntDictionary[kvp.Value];
1003:                      //else dictionary[key] = null;
1004:                  }
1005:   
1006:                  return dictionary;
1007:              }
1008:          }
1009:   
1010:          ////////////////////////////////////////////////////////////////////////////
1011:   
1012:          /// <summary>
1013:          ///
1014:          /// </summary>
1015:          public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> ServiceToSiteDictionary
1016:          {
1017:              get
1018:              {
1019:                  int fourLetterServiceDomain, fiveLetterServiceDomain;
1020:                  string service;
1021:                  Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> dictionary;
1022:   
1023:                  var serviceIdList = Ia.Ngn.Cl.Model.Data.Service2.ServiceIdList;
1024:                  var routerDomainToSiteDictionary = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.RouterDomainToSiteDictionary;
1025:   
1026:                  dictionary = new Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site>(serviceIdList.Count);
1027:   
1028:                  foreach (string s in serviceIdList)
1029:                  {
1030:                      service = Ia.Ngn.Cl.Model.Business.Service.ServiceIdToService(s);
1031:   
1032:                      if (service.Length >= 5)
1033:                      {
1034:                          fourLetterServiceDomain = int.Parse(service.Substring(0, 4));
1035:                          fiveLetterServiceDomain = int.Parse(service.Substring(0, 5));
1036:   
1037:                          if (routerDomainToSiteDictionary.ContainsKey(fiveLetterServiceDomain)) dictionary[service] = routerDomainToSiteDictionary[fiveLetterServiceDomain];
1038:                          else if (routerDomainToSiteDictionary.ContainsKey(fourLetterServiceDomain)) dictionary[service] = routerDomainToSiteDictionary[fourLetterServiceDomain];
1039:                          //else throw new System.ArgumentOutOfRangeException("Service number " + service + " is out of range");
1040:                      }
1041:                      //else throw new System.ArgumentOutOfRangeException("Service number " + service + " is out of range");
1042:                  }
1043:   
1044:                  return dictionary;
1045:              }
1046:          }
1047:   
1048:          ////////////////////////////////////////////////////////////////////////////
1049:   
1050:          /// <summary>
1051:          ///
1052:          /// </summary>
1053:          public static Dictionary<string, string> ServiceNotInServiceRequestServiceToSiteDictionary
1054:          {
1055:              get
1056:              {
1057:                  string service, siteName;
1058:                  Dictionary<string, string> dictionary;
1059:   
1060:                  var serviceToSiteNameDictionary = Ia.Ngn.Cl.Model.Data.Service2.ServiceToSiteDictionary;
1061:                  var serviceRequestServiceServiceToSiteNameDictionary = Ia.Ngn.Cl.Model.Data.ServiceRequestService.ServiceToSiteDictionary;
1062:   
1063:                  dictionary = new Dictionary<string, string>();
1064:   
1065:                  foreach (var kvp in serviceToSiteNameDictionary)
1066:                  {
1067:                      service = kvp.Key;
1068:                      siteName = kvp.Value.Name;
1069:   
1070:                      if (!serviceRequestServiceServiceToSiteNameDictionary.ContainsKey(service)) dictionary.Add(service, siteName);
1071:                  }
1072:   
1073:                  return dictionary;
1074:              }
1075:          }
1076:   
1077:          ////////////////////////////////////////////////////////////////////////////
1078:   
1079:          /// <summary>
1080:          ///
1081:          /// </summary>
1082:          public static Dictionary<string, string> ServiceNotInProvisionedServiceRequestServiceToSiteDictionary
1083:          {
1084:              get
1085:              {
1086:                  string service, siteName;
1087:                  Dictionary<string, string> dictionary;
1088:   
1089:                  var serviceToSiteNameDictionary = Ia.Ngn.Cl.Model.Data.Service2.ServiceToSiteDictionary;
1090:                  var serviceRequestServiceProvisionedServiceToSiteNameDictionary = Ia.Ngn.Cl.Model.Data.ServiceRequestService.ProvisionedServiceToSiteDictionary;
1091:   
1092:                  dictionary = new Dictionary<string, string>();
1093:   
1094:                  foreach (var kvp in serviceToSiteNameDictionary)
1095:                  {
1096:                      service = kvp.Key;
1097:                      siteName = kvp.Value.Name;
1098:   
1099:                      if (!serviceRequestServiceProvisionedServiceToSiteNameDictionary.ContainsKey(service)) dictionary.Add(service, siteName);
1100:                  }
1101:   
1102:                  return dictionary;
1103:              }
1104:          }
1105:   
1106:          ////////////////////////////////////////////////////////////////////////////
1107:   
1108:          /// <summary>
1109:          ///
1110:          /// </summary>
1111:          public static void UpdatePstnServiceAccessAndPort(string service, string updatedAccessId, int updatedPort, Guid userId, out Ia.Cl.Model.Result result)
1112:          {
1113:              int serviceType;
1114:              string service2Id;
1115:              Ia.Ngn.Cl.Model.Service2 service2;
1116:   
1117:              result = new Ia.Cl.Model.Result();
1118:   
1119:              serviceType = Ia.Ngn.Cl.Model.Business.Service.ServiceType.PstnService; // PSTN
1120:              service2Id = Ia.Ngn.Cl.Model.Business.Service2.ServiceId(service, serviceType);
1121:   
1122:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
1123:              {
1124:                  service2 = (from s in db.Service2s where s.Id == service2Id select s).SingleOrDefault();
1125:   
1126:                  if (service2 != null)
1127:                  {
1128:                      if (!string.IsNullOrEmpty(updatedAccessId))
1129:                      {
1130:                          if (service2.Access != null && service2.Access.Id != updatedAccessId || service2.Port != updatedPort)
1131:                          {
1132:                              service2.Access = (from a in db.Accesses where a.Id == updatedAccessId select a).SingleOrDefault();
1133:                              service2.Port = updatedPort;
1134:                              service2.UserId = userId;
1135:   
1136:                              db.Service2s.Attach(service2);
1137:                              db.Entry(service2).State = System.Data.Entity.EntityState.Modified;
1138:   
1139:                              db.SaveChanges();
1140:   
1141:                              result.AddSuccess("Service " + service + " was updated with access " + service2.Access.Name + " and port " + service2.Port + ". ");
1142:                          }
1143:                          else
1144:                          {
1145:                              result.AddWarning("Service access and port values were not updated because submitted data is the same as current data. ");
1146:                          }
1147:                      }
1148:                      else //if(string.IsNullOrEmpty(updatedAccessId))
1149:                      {
1150:                          if (service2.Access != null || service2.Port != -1)
1151:                          {
1152:                              service2.Access = (from a in db.Accesses where a.Id == string.Empty select a).SingleOrDefault();
1153:                              service2.Port = -1;
1154:                              service2.UserId = userId;
1155:   
1156:                              db.Service2s.Attach(service2);
1157:                              db.Entry(service2).State = System.Data.Entity.EntityState.Modified;
1158:   
1159:                              db.SaveChanges();
1160:   
1161:                              result.AddSuccess("Service " + service + " was updated with null access and -1 port. ");
1162:                          }
1163:                          else
1164:                          {
1165:                              result.AddWarning("Service access and port values were not resetted because submitted data (access null and port -1) is the same as current data. ");
1166:                          }
1167:                      }
1168:                  }
1169:                  else
1170:                  {
1171:                      result.AddWarning("Service does not exist. ");
1172:                  }
1173:              }
1174:          }
1175:   
1176:          ////////////////////////////////////////////////////////////////////////////
1177:          ////////////////////////////////////////////////////////////////////////////
1178:      }
1179:   
1180:      ////////////////////////////////////////////////////////////////////////////
1181:      ////////////////////////////////////////////////////////////////////////////
1182:  }