)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
Integrated Applications Programming Company
Home » Code Library » ServiceRequest (Ia.Ftn.Cl.Models)

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

Service Request Entity Framework class for Fixed Telecommunications Network (FTN) entity model.

    1: using Microsoft.EntityFrameworkCore.Metadata.Internal;
    2: using System;
    3: using System.Collections.Generic;
    4: using System.ComponentModel.DataAnnotations;
    5: using System.ComponentModel.DataAnnotations.Schema;
    6: using System.Linq;
    7: using System.Runtime.Serialization;
    8: using System.Threading;
    9: using System.Threading.Tasks;
   10:  
   11: namespace Ia.Ftn.Cl.Models
   12: {
   13:     ////////////////////////////////////////////////////////////////////////////
   14:  
   15:     /// <summary publish="true">
   16:     /// Service Request Entity Framework class for Fixed Telecommunications Network (FTN) entity model.
   17:     /// </summary>
   18:     /// 
   19:     /// <remarks> 
   20:     /// Copyright © 2006-2021 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   21:     ///
   22:     /// 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
   23:     /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
   24:     ///
   25:     /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
   26:     /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
   27:     /// 
   28:     /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
   29:     /// 
   30:     /// Copyright notice: This notice may not be removed or altered from any source distribution.
   31:     /// </remarks> 
   32:     [DataContract(IsReference = true, Namespace = "kw.com.ia.ftn.api", Name = "ServiceRequest")]
   33:     public class ServiceRequest
   34:     {
   35:         /// <summary/>
   36:         public ServiceRequest()
   37:         {
   38:         }
   39:  
   40:         /// <summary/>
   41:         [DataMember]
   42:         [Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
   43:         public int Id { get; set; }
   44:  
   45:         /// <summary/>
   46:         [DataMember]
   47:         public int Number { get; set; }
   48:  
   49:         /// <summary/>
   50:         [DataMember]
   51:         public int Serial { get; set; }
   52:  
   53:         /// <summary/>
   54:         [DataMember]
   55:         public int Status { get; set; }
   56:  
   57:         /// <summary/>
   58:         [DataMember]
   59:         public DateTime RequestDateTime { get; set; }
   60:  
   61:         /// <summary/>
   62:         [DataMember]
   63:         public int CustomerId { get; set; }
   64:  
   65:         /// <summary/>
   66:         [DataMember]
   67:         public string CustomerName { get; set; }
   68:  
   69:         /// <summary/>
   70:         [DataMember]
   71:         public int CustomerCategoryId { get; set; }
   72:  
   73:         /// <summary/>
   74:         [DataMember]
   75:         public string CustomerAddress { get; set; }
   76:  
   77:         /// <summary/>
   78:         [DataMember]
   79:         public int AreaId { get; set; }
   80:  
   81:         /// <summary/>
   82:         [DataMember]
   83:         public int ServiceId { get; set; }
   84:  
   85:         /// <summary/>
   86:         [DataMember]
   87:         public int ServiceCategoryId { get; set; }
   88:  
   89:         /// <summary/>
   90:         [DataMember]
   91:         public double Balance { get; set; }
   92:  
   93:         /// <summary/>
   94:         [DataMember]
   95:         public DateTime Created { get; set; }
   96:  
   97:         /// <summary/>
   98:         [DataMember]
   99:         public DateTime Updated { get; set; }
  100:  
  101:         /// <summary/>
  102:         [ForeignKey("ServiceRequestService_Id")]
  103:         public virtual ServiceRequestService ServiceRequestService { get; set; }
  104:  
  105:         /// <summary/>
  106:         public virtual ICollection<ServiceRequestType> ServiceRequestTypes { get; set; }
  107:  
  108:         /// <summary/>
  109:         //public virtual ICollection<ServiceRequestOnt> ServiceRequestOnts { get; set; }
  110:  
  111:         ////////////////////////////////////////////////////////////////////////////
  112:  
  113:         /// <summary>
  114:         ///
  115:         /// </summary>
  116:         public bool UpdateSkipServiceRequestServiceAndCheckIfOnlyBalanceWasUpdated(ServiceRequest updatedServiceRequest, out bool onlyBalanceWasUpdated)
  117:         {
  118:             return Update(updatedServiceRequest, true, out onlyBalanceWasUpdated);
  119:         }
  120:  
  121:         ////////////////////////////////////////////////////////////////////////////
  122:  
  123:         /// <summary>
  124:         ///
  125:         /// </summary>
  126:         public bool UpdateSkipServiceRequestService(ServiceRequest updatedServiceRequest)
  127:         {
  128:             return Update(updatedServiceRequest, true, out _);
  129:         }
  130:  
  131:         ////////////////////////////////////////////////////////////////////////////
  132:  
  133:         /// <summary>
  134:         ///
  135:         /// </summary>
  136:         public bool Update(ServiceRequest updatedServiceRequest)
  137:         {
  138:             return Update(updatedServiceRequest, false, out _);
  139:         }
  140:  
  141:         ////////////////////////////////////////////////////////////////////////////
  142:  
  143:         /// <summary>
  144:         ///
  145:         /// </summary>
  146:         private bool Update(ServiceRequest updatedServiceRequest, bool skipServiceRequestService, out bool onlyBalanceWasUpdated)
  147:         {
  148:             // below: this will not update Id, Created
  149:             bool updated, balanceWasUpdated;
  150:  
  151:             updated = false;
  152:             balanceWasUpdated = false;
  153:  
  154:             if (this.CustomerAddress != updatedServiceRequest.CustomerAddress) { this.CustomerAddress = updatedServiceRequest.CustomerAddress; updated = true; }
  155:             if (this.AreaId != updatedServiceRequest.AreaId) { this.AreaId = updatedServiceRequest.AreaId; updated = true; }
  156:             if (this.CustomerCategoryId != updatedServiceRequest.CustomerCategoryId) { this.CustomerCategoryId = updatedServiceRequest.CustomerCategoryId; updated = true; }
  157:             if (this.CustomerId != updatedServiceRequest.CustomerId) { this.CustomerId = updatedServiceRequest.CustomerId; updated = true; }
  158:             if (this.CustomerName != updatedServiceRequest.CustomerName) { this.CustomerName = updatedServiceRequest.CustomerName; updated = true; }
  159:             if (this.Number != updatedServiceRequest.Number) { this.Number = updatedServiceRequest.Number; updated = true; }
  160:             if (this.RequestDateTime != updatedServiceRequest.RequestDateTime) { this.RequestDateTime = updatedServiceRequest.RequestDateTime; updated = true; }
  161:             if (this.Serial != updatedServiceRequest.Serial) { this.Serial = updatedServiceRequest.Serial; updated = true; }
  162:             if (this.ServiceCategoryId != updatedServiceRequest.ServiceCategoryId) { this.ServiceCategoryId = updatedServiceRequest.ServiceCategoryId; updated = true; }
  163:             if (this.ServiceId != updatedServiceRequest.ServiceId) { this.ServiceId = updatedServiceRequest.ServiceId; updated = true; }
  164:  
  165:             if (!skipServiceRequestService) if (this.ServiceRequestService != updatedServiceRequest.ServiceRequestService) { this.ServiceRequestService = updatedServiceRequest.ServiceRequestService; updated = true; }
  166:             //if (this.ServiceRequestOnts != updatedServiceRequest.ServiceRequestOnts) { this.ServiceRequestOnts = updatedServiceRequest.ServiceRequestOnts; updated = true; }
  167:             //if (this.ServiceRequestTypes != updatedServiceRequest.ServiceRequestTypes) { this.ServiceRequestTypes = updatedServiceRequest.ServiceRequestTypes; updated = true; }
  168:  
  169:             if (this.Status != updatedServiceRequest.Status) { this.Status = updatedServiceRequest.Status; updated = true; }
  170:             if (this.Balance != updatedServiceRequest.Balance) { this.Balance = updatedServiceRequest.Balance; balanceWasUpdated = true; }
  171:  
  172:             if (updated || balanceWasUpdated) this.Updated = DateTime.UtcNow.AddHours(3);
  173:  
  174:             onlyBalanceWasUpdated = balanceWasUpdated && !updated;
  175:  
  176:             return updated;
  177:         }
  178:  
  179:         ////////////////////////////////////////////////////////////////////////////
  180:         ////////////////////////////////////////////////////////////////////////////
  181:  
  182:         /// <summary>
  183:         ///
  184:         /// </summary>
  185:         public string ToSimpleTextString()
  186:         {
  187:             return Ia.Ftn.Cl.Models.Data.ServiceRequest.ToSimpleTextString(this);
  188:         }
  189:  
  190:         ////////////////////////////////////////////////////////////////////////////
  191:         ////////////////////////////////////////////////////////////////////////////
  192:     }
  193:  
  194:     ////////////////////////////////////////////////////////////////////////////
  195:     ////////////////////////////////////////////////////////////////////////////
  196: }