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

Integrated Applications Programming Company

Skip Navigation LinksHome » Code Library » Transaction

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

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

   1:  using System;
   2:  using System.Web;
   3:  using System.Xml;
   4:  using System.Xml.Linq;
   5:  using System.IO;
   6:  using System.Configuration;
   7:  using System.Text;
   8:  using System.Text.RegularExpressions;
   9:  using System.Data;
  10:  using System.Data.SqlClient;
  11:  using System.Web.UI;
  12:  using System.Web.UI.WebControls;
  13:  using System.Collections;
  14:  using System.Collections.Generic;
  15:  using System.Reflection;
  16:  using System.Linq;
  17:   
  18:  namespace Ia.Ngn.Cl.Model
  19:  {
  20:      ////////////////////////////////////////////////////////////////////////////
  21:   
  22:      /// <summary publish="true">
  23:      /// Transaction Entity Framework class for Next Generation Network (NGN) entity model.
  24:      /// </summary>
  25:      /// 
  26:      /// <remarks> 
  27:      /// Copyright © 2006-2017 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet Applications - Kuwait. All Rights Reserved.
  28:      ///
  29:      /// 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
  30:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  31:      ///
  32:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  33:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  34:      /// 
  35:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  36:      /// 
  37:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  38:      /// </remarks> 
  39:      public partial class Transaction
  40:      {
  41:          ////////////////////////////////////////////////////////////////////////////
  42:   
  43:          /// <summary>
  44:          ///
  45:          /// </summary>
  46:          public Transaction() { }
  47:   
  48:          /// <summary/>
  49:          public int Id { get; set; }
  50:   
  51:          /// <summary/>
  52:          public int TypeId { get; set; }
  53:   
  54:          /// <summary/>
  55:          public int StateId { get; set; }
  56:   
  57:          /// <summary/>
  58:          public int PriorityId { get; set; }
  59:   
  60:          /// <summary/>
  61:          public int RecipientId { get; set; }
  62:   
  63:          /// <summary/>
  64:          public int NumberOfTimesMessageSent { get; set; }
  65:   
  66:          /// <summary/>
  67:          public bool Closed { get; set; }
  68:   
  69:          /// <summary/>
  70:          public string Message { get; set; }
  71:   
  72:          /// <summary/>
  73:          public DateTime? MessageSent { get; set; }
  74:   
  75:          /// <summary/>
  76:          public string Response { get; set; }
  77:   
  78:          /// <summary/>
  79:          public DateTime? ResponseReceived { get; set; }
  80:   
  81:          /// <summary/>
  82:          public DateTime Created { get; set; }
  83:   
  84:          /// <summary/>
  85:          public DateTime Updated { get; set; }
  86:   
  87:          /// <summary/>
  88:          public System.Guid UserId { get; set; }
  89:   
  90:          ////////////////////////////////////////////////////////////////////////////    
  91:          ////////////////////////////////////////////////////////////////////////////    
  92:   
  93:          /// <summary>
  94:          ///
  95:          /// </summary>
  96:          public static bool Create(Transaction newItem, out int itemId)
  97:          {
  98:              bool b;
  99:   
 100:              b = false;
 101:   
 102:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 103:              {
 104:                  newItem.Created = newItem.Updated = DateTime.UtcNow.AddHours(3);
 105:   
 106:                  db.Transactions.Add(newItem);
 107:                  db.SaveChanges();
 108:   
 109:                  itemId = newItem.Id;
 110:   
 111:                  b = true;
 112:              }
 113:   
 114:              return b;
 115:          }
 116:   
 117:          ////////////////////////////////////////////////////////////////////////////
 118:   
 119:          /// <summary>
 120:          ///
 121:          /// </summary>
 122:          public static Transaction Read(int id)
 123:          {
 124:              Transaction item;
 125:   
 126:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 127:              {
 128:                  item = (from t in db.Transactions where t.Id == id select t).SingleOrDefault();
 129:              }
 130:   
 131:              return item;
 132:          }
 133:   
 134:          ////////////////////////////////////////////////////////////////////////////
 135:   
 136:          /// <summary>
 137:          ///
 138:          /// </summary>
 139:          public static List<Transaction> ReadList()
 140:          {
 141:              List<Transaction> itemList;
 142:   
 143:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 144:              {
 145:                  itemList = (from t in db.Transactions select t).ToList();
 146:              }
 147:   
 148:              return itemList;
 149:          }
 150:   
 151:          ////////////////////////////////////////////////////////////////////////////
 152:   
 153:          /// <summary>
 154:          ///
 155:          /// </summary>
 156:          public static bool Update(Transaction updatedItem, out string result)
 157:          {
 158:              bool b;
 159:   
 160:              b = false;
 161:              result = string.Empty;
 162:   
 163:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 164:              {
 165:                  updatedItem = (from t in db.Transactions where t.Id == updatedItem.Id select t).SingleOrDefault();
 166:   
 167:                  updatedItem.Updated = DateTime.UtcNow.AddHours(3);
 168:   
 169:                  db.Transactions.Attach(updatedItem);
 170:   
 171:                  var v = db.Entry(updatedItem);
 172:                  v.State = System.Data.Entity.EntityState.Modified;
 173:                  db.SaveChanges();
 174:   
 175:                  b = true;
 176:              }
 177:   
 178:              return b;
 179:          }
 180:   
 181:          ////////////////////////////////////////////////////////////////////////////
 182:   
 183:          /// <summary>
 184:          ///
 185:          /// </summary>
 186:          public bool Update(Transaction transactionOnt)
 187:          {
 188:              // below: this will not update Id, Created
 189:              bool updated;
 190:   
 191:              updated = false;
 192:   
 193:              if (this.Closed != transactionOnt.Closed) { this.Closed = transactionOnt.Closed; updated = true; }
 194:              else if (this.Message != transactionOnt.Message) { this.Message = transactionOnt.Message; updated = true; }
 195:              else if (this.MessageSent != transactionOnt.MessageSent) { this.MessageSent = transactionOnt.MessageSent; updated = true; }
 196:              else if (this.NumberOfTimesMessageSent != transactionOnt.NumberOfTimesMessageSent) { this.NumberOfTimesMessageSent = transactionOnt.NumberOfTimesMessageSent; updated = true; }
 197:              else if (this.PriorityId != transactionOnt.PriorityId) { this.PriorityId = transactionOnt.PriorityId; updated = true; }
 198:              else if (this.RecipientId != transactionOnt.RecipientId) { this.RecipientId = transactionOnt.RecipientId; updated = true; }
 199:              else if (this.Response != transactionOnt.Response) { this.Response = transactionOnt.Response; updated = true; }
 200:              else if (this.ResponseReceived != transactionOnt.ResponseReceived) { this.ResponseReceived = transactionOnt.ResponseReceived; updated = true; }
 201:              else if (this.StateId != transactionOnt.StateId) { this.StateId = transactionOnt.StateId; updated = true; }
 202:              else if (this.TypeId != transactionOnt.TypeId) { this.TypeId = transactionOnt.TypeId; updated = true; }
 203:              else if (this.UserId != transactionOnt.UserId) { this.UserId = transactionOnt.UserId; updated = true; }
 204:   
 205:              if (updated) this.Updated = DateTime.UtcNow.AddHours(3);
 206:   
 207:              return updated;
 208:          }
 209:   
 210:          ////////////////////////////////////////////////////////////////////////////
 211:   
 212:          /// <summary>
 213:          ///
 214:          /// </summary>
 215:          public static bool Delete(int id, out string result)
 216:          {
 217:              bool b;
 218:   
 219:              b = false;
 220:              result = string.Empty;
 221:   
 222:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 223:              {
 224:                  var v = (from t in db.Transactions where t.Id == id select t).FirstOrDefault();
 225:   
 226:                  db.Transactions.Remove(v);
 227:                  db.SaveChanges();
 228:   
 229:                  b = true;
 230:              }
 231:   
 232:              return b;
 233:          }
 234:   
 235:          ////////////////////////////////////////////////////////////////////////////
 236:          ////////////////////////////////////////////////////////////////////////////
 237:      }
 238:   
 239:      ////////////////////////////////////////////////////////////////////////////
 240:      ////////////////////////////////////////////////////////////////////////////   
 241:  }