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

Integrated Applications Programming Company

Skip Navigation LinksHome » Code Library » Individual

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

Individual object.

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