)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
Integrated Applications Programming Company
Skip Navigation LinksHome » Code Library » Score

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

Score entity functions

    1:  
    2: namespace Ia.TentPlay.Cl.Model.Memorise
    3: {
    4:     ////////////////////////////////////////////////////////////////////////////
    5:  
    6:     /// <summary publish="true">
    7:     /// Score entity functions
    8:     /// </summary>
    9:     /// <value>
   10:     /// https://msdn.microsoft.com/en-us/library/z1hkazw7(v=vs.100).aspx
   11:     /// </value>
   12:     /// <remarks> 
   13:     /// Copyright © 2008-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:     public partial class Score
   26:     {
   27:         /// <summary/>
   28:         public Score()
   29:         {
   30:         }
   31:  
   32:         /// <summary/>
   33:         public int Id { get; set; }
   34:  
   35:         /// <summary/>
   36:         public int TestId { get; set; }
   37:  
   38:         /// <summary/>
   39:         public int TypeId { get; set; }
   40:  
   41:         /// <summary/>
   42:         public string Question { get; set; }
   43:  
   44:         /// <summary/>
   45:         public string Answer { get; set; }
   46:  
   47:         /// <summary/>
   48:         public int NumberOfTimesAsked { get; set; }
   49:  
   50:         /// <summary/>
   51:         public int CumulativeAnswerCorrectnessIndicator { get; set; }
   52:  
   53:         /// <summary/>
   54:         public int NumberOfConsecutiveCorrects { get; set; }
   55:  
   56:         /// <summary/>
   57:         public DateTime Created { get; set; }
   58:  
   59:         /// <summary/>
   60:         public DateTime Updated { get; set; }
   61:  
   62:         /// <summary/>
   63:         public DateTime Viewed { get; set; }
   64:  
   65:         /// <summary/>
   66:         public System.Guid UserId { get; set; }
   67:  
   68:         ////////////////////////////////////////////////////////////////////////////
   69:  
   70:         /// <summary>
   71:         ///
   72:         /// </summary>
   73:         public static List<Ia.TentPlay.Cl.Model.Memorise.Score> List(Ia.TentPlay.Cl.Model.Memorise.Test.TestTopic testTopic, int numberOfRecordsToTake, out Ia.Cl.Model.Result result)
   74:         {
   75:             List<Ia.TentPlay.Cl.Model.Memorise.Score> list;
   76:  
   77:             result = new Ia.Cl.Model.Result();
   78:  
   79:             using (var db = new Ia.TentPlay.Db())
   80:             {
   81:                 list = (from s in db.Scores where s.TestId == (int)testTopic select s).Take(numberOfRecordsToTake).ToList();
   82:             }
   83:  
   84:             result.AddSuccess("Number of records (" + testTopic + "): " + list.Count);
   85:  
   86:             return list;
   87:         }
   88:  
   89:         ////////////////////////////////////////////////////////////////////////////
   90:  
   91:         /// <summary>
   92:         ///
   93:         /// </summary>
   94:         public static List<Ia.TentPlay.Cl.Model.Memorise.Score> List(Ia.TentPlay.Cl.Model.Memorise.Test.TestTopic testTopic, out Ia.Cl.Model.Result result)
   95:         {
   96:             List<Ia.TentPlay.Cl.Model.Memorise.Score> list;
   97:  
   98:             result = new Ia.Cl.Model.Result();
   99:  
  100:             using (var db = new Ia.TentPlay.Db())
  101:             {
  102:                 list = (from s in db.Scores where s.TestId == (int)testTopic select s).ToList();
  103:             }
  104:  
  105:             result.AddSuccess("Number of records (" + testTopic + "): " + list.Count);
  106:  
  107:             return list;
  108:         }
  109:  
  110:         ////////////////////////////////////////////////////////////////////////////
  111:  
  112:         /// <summary>
  113:         ///
  114:         /// </summary>
  115:         public static void Delete(Ia.TentPlay.Cl.Model.Memorise.Test.TestTopic testTopic, out Ia.Cl.Model.Result result)
  116:         {
  117:             int c;
  118:  
  119:             result = new Ia.Cl.Model.Result();
  120:  
  121:             /*
  122:             int count;
  123:             Ia.Cl.Model.Db.SqlServer sqlServer;
  124: 
  125:             result = new Ia.Cl.Model.Result();
  126:             sqlServer = new Ia.Cl.Model.Db.SqlServer(Ia.TentPlay.Db.Configuration["ConnectionStrings:DefaultConnection"]);
  127: 
  128:             count = sqlServer.ScalarInteger("select count(0) from Features where FileCountry = '" + fileCountry + "'");
  129: 
  130:             sqlServer.Sql("delete from Features where FileCountry = '" + fileCountry + "'");
  131: 
  132:             result.AddSuccess("Deleted row count (" + fileCountry + "): " + count + ". ");
  133:             */
  134:  
  135:             try
  136:             {
  137:                 using (var db = new Ia.TentPlay.Db())
  138:                 {
  139:                     var list = from s in db.Scores where s.TestId == (int)testTopic select s;
  140:  
  141:                     c = list.Count();
  142:  
  143:                     db.Scores.RemoveRange(list);
  144:                     db.SaveChanges();
  145:  
  146:                     result.AddSuccess("Scores: " + c + " deleted for TestTopic " + testTopic + ". ");
  147:                 }
  148:             }
  149:             catch (Exception ex)
  150:             {
  151:                 result.AddError(ex.ToString());
  152:             }
  153:         }
  154:  
  155:         ////////////////////////////////////////////////////////////////////////////
  156:  
  157:         /// <summary>
  158:         ///
  159:         /// </summary>
  160:         public static List<Score> GermanScoreList(Guid userId)
  161:         {
  162:             return ScoreList(Ia.TentPlay.Cl.Model.Memorise.Test.TestTopic.German, userId);
  163:         }
  164:  
  165:         ////////////////////////////////////////////////////////////////////////////
  166:  
  167:         /// <summary>
  168:         ///
  169:         /// </summary>
  170:         public static List<Score> RussianScoreList(Guid userId)
  171:         {
  172:             return ScoreList(Ia.TentPlay.Cl.Model.Memorise.Test.TestTopic.Russian, userId);
  173:         }
  174:  
  175:         ////////////////////////////////////////////////////////////////////////////
  176:  
  177:         /// <summary>
  178:         ///
  179:         /// </summary>
  180:         public static List<Score> MathScoreList(Guid userId)
  181:         {
  182:             return ScoreList(Ia.TentPlay.Cl.Model.Memorise.Test.TestTopic.Math, userId);
  183:         }
  184:  
  185:         ////////////////////////////////////////////////////////////////////////////
  186:  
  187:         /// <summary>
  188:         ///
  189:         /// </summary>
  190:         public static List<Score> KanjiScoreList(Guid userId)
  191:         {
  192:             return ScoreList(Ia.TentPlay.Cl.Model.Memorise.Test.TestTopic.Kanji, userId);
  193:         }
  194:  
  195:         ////////////////////////////////////////////////////////////////////////////
  196:  
  197:         /// <summary>
  198:         ///
  199:         /// </summary>
  200:         public static List<Score> KanaScoreList(Guid userId)
  201:         {
  202:             return ScoreList(Ia.TentPlay.Cl.Model.Memorise.Test.TestTopic.Kana, userId);
  203:         }
  204:  
  205:         ////////////////////////////////////////////////////////////////////////////
  206:  
  207:         /// <summary>
  208:         ///
  209:         /// </summary>
  210:         public static List<Score> PhoneticAlphabetScoreList(Guid userId)
  211:         {
  212:             return ScoreList(Ia.TentPlay.Cl.Model.Memorise.Test.TestTopic.PhoneticAlphabet, userId);
  213:         }
  214:  
  215:         ////////////////////////////////////////////////////////////////////////////
  216:  
  217:         /// <summary>
  218:         ///
  219:         /// </summary>
  220:         [Obsolete("Not used. ")]
  221:         private static List<Score> ScoreList(Ia.TentPlay.Cl.Model.Memorise.Test.TestTopic testList)
  222:         {
  223:             List<Score> list;
  224:  
  225:             using (var db = new Ia.TentPlay.Db())
  226:             {
  227:                 list = (from s in db.Scores where s.TestId == (int)testList select s).ToList();
  228:             }
  229:  
  230:             return list;
  231:         }
  232:  
  233:         ////////////////////////////////////////////////////////////////////////////
  234:  
  235:         /// <summary>
  236:         ///
  237:         /// </summary>
  238:         private static List<Score> ScoreList(Ia.TentPlay.Cl.Model.Memorise.Test.TestTopic testList, Guid userId)
  239:         {
  240:             List<Score> list;
  241:  
  242:             using (var db = new Ia.TentPlay.Db())
  243:             {
  244:                 list = (from s in db.Scores where s.TestId == (int)testList && s.UserId == userId select s).ToList();
  245:             }
  246:  
  247:             return list;
  248:         }
  249:  
  250:         ////////////////////////////////////////////////////////////////////////////
  251:         ////////////////////////////////////////////////////////////////////////////
  252:     }
  253:  
  254:     ////////////////////////////////////////////////////////////////////////////
  255:     ////////////////////////////////////////////////////////////////////////////
  256: }