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

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

Score entity functions

    1:  
    2: using System;
    3: using System.Linq;
    4: using System.Collections.Generic;
    5: using System.IO;
    6:  
    7: namespace Ia.TentPlay.Cl.Models.Memorise
    8: {
    9:     ////////////////////////////////////////////////////////////////////////////
   10:  
   11:     /// <summary publish="true">
   12:     /// Score entity functions
   13:     /// </summary>
   14:     /// <value>
   15:     /// https://msdn.microsoft.com/en-us/library/z1hkazw7(v=vs.100).aspx
   16:     /// </value>
   17:     /// <remarks> 
   18:     /// Copyright © 2008-2015 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   19:     ///
   20:     /// 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
   21:     /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
   22:     ///
   23:     /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
   24:     /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
   25:     /// 
   26:     /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
   27:     /// 
   28:     /// Copyright notice: This notice may not be removed or altered from any source distribution.
   29:     /// </remarks> 
   30:     public partial class Score
   31:     {
   32:         /// <summary/>
   33:         public Score()
   34:         {
   35:         }
   36:  
   37:         /// <summary/>
   38:         public int Id { get; set; }
   39:  
   40:         /// <summary/>
   41:         public int TestId { get; set; }
   42:  
   43:         /// <summary/>
   44:         public int TypeId { get; set; }
   45:  
   46:         /// <summary/>
   47:         public string Question { get; set; }
   48:  
   49:         /// <summary/>
   50:         public string Answer { get; set; }
   51:  
   52:         /// <summary/>
   53:         public int NumberOfTimesAsked { get; set; }
   54:  
   55:         /// <summary/>
   56:         public int CumulativeAnswerCorrectnessIndicator { get; set; }
   57:  
   58:         /// <summary/>
   59:         public int NumberOfConsecutiveCorrects { get; set; }
   60:  
   61:         /// <summary/>
   62:         public DateTime Created { get; set; }
   63:  
   64:         /// <summary/>
   65:         public DateTime Updated { get; set; }
   66:  
   67:         /// <summary/>
   68:         public DateTime Viewed { get; set; }
   69:  
   70:         /// <summary/>
   71:         public System.Guid UserId { get; set; }
   72:  
   73:         ////////////////////////////////////////////////////////////////////////////
   74:  
   75:         /// <summary>
   76:         ///
   77:         /// </summary>
   78:         public static List<Ia.TentPlay.Cl.Models.Memorise.Score> List(Ia.TentPlay.Cl.Models.Memorise.Test.TestTopic testTopic, int numberOfRecordsToTake, out Ia.Cl.Models.Result result)
   79:         {
   80:             List<Ia.TentPlay.Cl.Models.Memorise.Score> list;
   81:  
   82:             result = new Ia.Cl.Models.Result();
   83:  
   84:             using (var db = new Ia.TentPlay.Db())
   85:             {
   86:                 list = (from s in db.Scores where s.TestId == (int)testTopic select s).Take(numberOfRecordsToTake).ToList();
   87:             }
   88:  
   89:             result.AddSuccess("Number of records (" + testTopic + "): " + list.Count);
   90:  
   91:             return list;
   92:         }
   93:  
   94:         ////////////////////////////////////////////////////////////////////////////
   95:  
   96:         /// <summary>
   97:         ///
   98:         /// </summary>
   99:         public static List<Ia.TentPlay.Cl.Models.Memorise.Score> List(Ia.TentPlay.Cl.Models.Memorise.Test.TestTopic testTopic, out Ia.Cl.Models.Result result)
  100:         {
  101:             List<Ia.TentPlay.Cl.Models.Memorise.Score> list;
  102:  
  103:             result = new Ia.Cl.Models.Result();
  104:  
  105:             using (var db = new Ia.TentPlay.Db())
  106:             {
  107:                 list = (from s in db.Scores where s.TestId == (int)testTopic select s).ToList();
  108:             }
  109:  
  110:             result.AddSuccess("Number of records (" + testTopic + "): " + list.Count);
  111:  
  112:             return list;
  113:         }
  114:  
  115:         ////////////////////////////////////////////////////////////////////////////
  116:  
  117:         /// <summary>
  118:         ///
  119:         /// </summary>
  120:         public static void Delete(Ia.TentPlay.Cl.Models.Memorise.Test.TestTopic testTopic, out Ia.Cl.Models.Result result)
  121:         {
  122:             int c;
  123:  
  124:             result = new Ia.Cl.Models.Result();
  125:  
  126:             /*
  127:             int count;
  128:             Ia.Cl.Models.Db.SqlServer sqlServer;
  129: 
  130:             result = new Ia.Cl.Models.Result();
  131:             sqlServer = new Ia.Cl.Models.Db.SqlServer(Ia.TentPlay.Db.Configuration["ConnectionStrings:DefaultConnection"]);
  132: 
  133:             count = sqlServer.ScalarInteger("select count(0) from Features where FileCountry = '" + fileCountry + "'");
  134: 
  135:             sqlServer.Sql("delete from Features where FileCountry = '" + fileCountry + "'");
  136: 
  137:             result.AddSuccess("Deleted row count (" + fileCountry + "): " + count + ". ");
  138:             */
  139:  
  140:             try
  141:             {
  142:                 using (var db = new Ia.TentPlay.Db())
  143:                 {
  144:                     var list = from s in db.Scores where s.TestId == (int)testTopic select s;
  145:  
  146:                     c = list.Count();
  147:  
  148:                     db.Scores.RemoveRange(list);
  149:                     db.SaveChanges();
  150:  
  151:                     result.AddSuccess("Scores: " + c + " deleted for TestTopic " + testTopic + ". ");
  152:                 }
  153:             }
  154:             catch (Exception ex)
  155:             {
  156:                 result.AddError(ex.ToString());
  157:             }
  158:         }
  159:  
  160:         ////////////////////////////////////////////////////////////////////////////
  161:  
  162:         /// <summary>
  163:         ///
  164:         /// </summary>
  165:         public static List<Score> GermanScoreList(Guid userId)
  166:         {
  167:             return ScoreList(Ia.TentPlay.Cl.Models.Memorise.Test.TestTopic.German, userId);
  168:         }
  169:  
  170:         ////////////////////////////////////////////////////////////////////////////
  171:  
  172:         /// <summary>
  173:         ///
  174:         /// </summary>
  175:         public static List<Score> RussianScoreList(Guid userId)
  176:         {
  177:             return ScoreList(Ia.TentPlay.Cl.Models.Memorise.Test.TestTopic.Russian, userId);
  178:         }
  179:  
  180:         ////////////////////////////////////////////////////////////////////////////
  181:  
  182:         /// <summary>
  183:         ///
  184:         /// </summary>
  185:         public static List<Score> MathScoreList(Guid userId)
  186:         {
  187:             return ScoreList(Ia.TentPlay.Cl.Models.Memorise.Test.TestTopic.Math, userId);
  188:         }
  189:  
  190:         ////////////////////////////////////////////////////////////////////////////
  191:  
  192:         /// <summary>
  193:         ///
  194:         /// </summary>
  195:         public static List<Score> KanjiScoreList(Guid userId)
  196:         {
  197:             return ScoreList(Ia.TentPlay.Cl.Models.Memorise.Test.TestTopic.Kanji, userId);
  198:         }
  199:  
  200:         ////////////////////////////////////////////////////////////////////////////
  201:  
  202:         /// <summary>
  203:         ///
  204:         /// </summary>
  205:         public static List<Score> KanaScoreList(Guid userId)
  206:         {
  207:             return ScoreList(Ia.TentPlay.Cl.Models.Memorise.Test.TestTopic.Kana, userId);
  208:         }
  209:  
  210:         ////////////////////////////////////////////////////////////////////////////
  211:  
  212:         /// <summary>
  213:         ///
  214:         /// </summary>
  215:         public static List<Score> PhoneticAlphabetScoreList(Guid userId)
  216:         {
  217:             return ScoreList(Ia.TentPlay.Cl.Models.Memorise.Test.TestTopic.PhoneticAlphabet, userId);
  218:         }
  219:  
  220:         ////////////////////////////////////////////////////////////////////////////
  221:  
  222:         /// <summary>
  223:         ///
  224:         /// </summary>
  225:         [Obsolete("Not used. ")]
  226:         private static List<Score> ScoreList(Ia.TentPlay.Cl.Models.Memorise.Test.TestTopic testList)
  227:         {
  228:             List<Score> list;
  229:  
  230:             using (var db = new Ia.TentPlay.Db())
  231:             {
  232:                 list = (from s in db.Scores where s.TestId == (int)testList select s).ToList();
  233:             }
  234:  
  235:             return list;
  236:         }
  237:  
  238:         ////////////////////////////////////////////////////////////////////////////
  239:  
  240:         /// <summary>
  241:         ///
  242:         /// </summary>
  243:         private static List<Score> ScoreList(Ia.TentPlay.Cl.Models.Memorise.Test.TestTopic testList, Guid userId)
  244:         {
  245:             List<Score> list;
  246:  
  247:             using (var db = new Ia.TentPlay.Db())
  248:             {
  249:                 list = (from s in db.Scores where s.TestId == (int)testList && s.UserId == userId select s).ToList();
  250:             }
  251:  
  252:             return list;
  253:         }
  254:  
  255:         ////////////////////////////////////////////////////////////////////////////
  256:         ////////////////////////////////////////////////////////////////////////////
  257:     }
  258:  
  259:     ////////////////////////////////////////////////////////////////////////////
  260:     ////////////////////////////////////////////////////////////////////////////
  261: }