Professional Applications Programmers/Consultants برمجة واستشارات تطبيقات الإنترنت
Skip Navigation LinksHome » Code Library » ServiceRequest

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

Service Request Entity Framework class for Next Generation Network (NGN) entity model.

   1:  using System;
   2:  using System.Collections.Generic;
   3:  using System.ComponentModel.DataAnnotations;
   4:  using System.ComponentModel.DataAnnotations.Schema;
   5:  using EntityFramework.Triggers;
   6:   
   7:  namespace Ia.Ngn.Cl.Model
   8:  {
   9:      ////////////////////////////////////////////////////////////////////////////
  10:   
  11:      /// <summary publish="true">
  12:      /// Service Request 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), Internet 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 ServiceRequest : ITriggerable
  29:      {
  30:          /// <summary/>
  31:          public ServiceRequest()
  32:          {
  33:              this.Triggers().Inserting += entry => { TriggeredInstanceQueue.Enqueue(entry.Entity); };
  34:              this.Triggers().Updating += entry => { TriggeredInstanceQueue.Enqueue(entry.Entity); };
  35:              this.Triggers().Deleting += entry => { TriggeredInstanceQueue.Enqueue(entry.Entity); };
  36:          }
  37:   
  38:          /// <summary/>
  39:          [Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
  40:          public int Id { get; set; }
  41:          /// <summary/>
  42:          public int Number { get; set; }
  43:          /// <summary/>
  44:          public int Serial { get; set; }
  45:          /// <summary/>
  46:          public int Status { get; set; }
  47:          /// <summary/>
  48:          public DateTime RequestDateTime { get; set; }
  49:          /// <summary/>
  50:          public int CustomerId { get; set; }
  51:          /// <summary/>
  52:          public string CustomerName { get; set; }
  53:          /// <summary/>
  54:          public int CustomerCategoryId { get; set; }
  55:          /// <summary/>
  56:          public string CustomerAddress { get; set; }
  57:          /// <summary/>
  58:          public int AreaId { get; set; }
  59:          /// <summary/>
  60:          public int ServiceId { get; set; }
  61:          /// <summary/>
  62:          public int ServiceCategoryId { get; set; }
  63:          /// <summary/>
  64:          public double Balance { get; set; }
  65:          /// <summary/>
  66:          public DateTime Created { get; set; }
  67:          /// <summary/>
  68:          public DateTime Updated { get; set; }
  69:          /// <summary/>
  70:          public System.Guid UserId { get; set; }
  71:   
  72:          /// <summary/>
  73:          public virtual ServiceRequestService ServiceRequestService { get; set; }
  74:          /// <summary/>
  75:          public virtual ICollection<ServiceRequestType> ServiceRequestTypes { get; set; }
  76:          /// <summary/>
  77:          public virtual ICollection<ServiceRequestOnt> ServiceRequestOnts { get; set; }
  78:   
  79:          /// <summary/>
  80:          [NotMapped]
  81:          public static Queue<ServiceRequest> TriggeredInstanceQueue = new Queue<ServiceRequest>();
  82:   
  83:          ////////////////////////////////////////////////////////////////////////////
  84:   
  85:          /// <summary>
  86:          ///
  87:          /// </summary>
  88:          public bool UpdateSkipServiceRequestService(ServiceRequest updatedServiceRequest)
  89:          {
  90:              return Update(updatedServiceRequest, true);
  91:          }
  92:   
  93:          ////////////////////////////////////////////////////////////////////////////
  94:   
  95:          /// <summary>
  96:          ///
  97:          /// </summary>
  98:          public bool Update(ServiceRequest updatedServiceRequest)
  99:          {
 100:              return Update(updatedServiceRequest, false);
 101:          }
 102:   
 103:          ////////////////////////////////////////////////////////////////////////////
 104:   
 105:          /// <summary>
 106:          ///
 107:          /// </summary>
 108:          private bool Update(ServiceRequest updatedServiceRequest, bool skipServiceRequestService)
 109:          {
 110:              // below: this will not update Id, Created
 111:              bool updated;
 112:   
 113:              updated = false;
 114:   
 115:              if (this.CustomerAddress != updatedServiceRequest.CustomerAddress) { this.CustomerAddress = updatedServiceRequest.CustomerAddress; updated = true; }
 116:              if (this.AreaId != updatedServiceRequest.AreaId) { this.AreaId = updatedServiceRequest.AreaId; updated = true; }
 117:              if (this.CustomerCategoryId != updatedServiceRequest.CustomerCategoryId) { this.CustomerCategoryId = updatedServiceRequest.CustomerCategoryId; updated = true; }
 118:              if (this.CustomerId != updatedServiceRequest.CustomerId) { this.CustomerId = updatedServiceRequest.CustomerId; updated = true; }
 119:              if (this.CustomerName != updatedServiceRequest.CustomerName) { this.CustomerName = updatedServiceRequest.CustomerName; updated = true; }
 120:              if (this.Number != updatedServiceRequest.Number) { this.Number = updatedServiceRequest.Number; updated = true; }
 121:              if (this.RequestDateTime != updatedServiceRequest.RequestDateTime) { this.RequestDateTime = updatedServiceRequest.RequestDateTime; updated = true; }
 122:              if (this.Serial != updatedServiceRequest.Serial) { this.Serial = updatedServiceRequest.Serial; updated = true; }
 123:              if (this.ServiceCategoryId != updatedServiceRequest.ServiceCategoryId) { this.ServiceCategoryId = updatedServiceRequest.ServiceCategoryId; updated = true; }
 124:              if (this.ServiceId != updatedServiceRequest.ServiceId) { this.ServiceId = updatedServiceRequest.ServiceId; updated = true; }
 125:   
 126:              if (!skipServiceRequestService) if (this.ServiceRequestService != updatedServiceRequest.ServiceRequestService) { this.ServiceRequestService = updatedServiceRequest.ServiceRequestService; updated = true; }
 127:              //if (this.ServiceRequestOnts != updatedServiceRequest.ServiceRequestOnts) { this.ServiceRequestOnts = updatedServiceRequest.ServiceRequestOnts; updated = true; }
 128:              //if (this.ServiceRequestTypes != updatedServiceRequest.ServiceRequestTypes) { this.ServiceRequestTypes = updatedServiceRequest.ServiceRequestTypes; updated = true; }
 129:   
 130:              if (this.Status != updatedServiceRequest.Status) { this.Status = updatedServiceRequest.Status; updated = true; }
 131:              if (this.Balance != updatedServiceRequest.Balance) { this.Balance = updatedServiceRequest.Balance; updated = true; }
 132:   
 133:              if (updated) this.Updated = DateTime.UtcNow.AddHours(3);
 134:   
 135:              return updated;
 136:          }
 137:   
 138:          ////////////////////////////////////////////////////////////////////////////
 139:          ////////////////////////////////////////////////////////////////////////////
 140:   
 141:          /// <summary>
 142:          ///
 143:          /// </summary>
 144:          public string ToSimpleTextString()
 145:          {
 146:              return Ia.Ngn.Cl.Model.Data.ServiceRequest.ToSimpleTextString(this);
 147:          }
 148:   
 149:          ////////////////////////////////////////////////////////////////////////////
 150:          ////////////////////////////////////////////////////////////////////////////
 151:      }
 152:   
 153:      ////////////////////////////////////////////////////////////////////////////
 154:      ////////////////////////////////////////////////////////////////////////////
 155:  }