コード例 #1
0
ファイル: BLStatistic.cs プロジェクト: alexanderkraemer/Wuhu
        public static void Insert(int playerId, int skill)
        {
            IDatabase     database = DalFactory.CreateDatabase();
            IStatisticDao dao      = DalFactory.CreateStatisticDao(database);

            dao.Insert(new Domain.Statistic(playerId, skill, DateTime.Now));
        }
コード例 #2
0
        public HttpResponseMessage GetAll()
        {
            //if (Authentication.getInstance().isAuthenticateWithHeader(Request))
            //{
            IStatisticDao StatisticDao = DalFactory.CreateStatisticDao(database);
            IPlayerDao    PlayerDao    = DalFactory.CreatePlayerDao(database);

            var retList = new List <Serialize>();

            int i = 0;

            foreach (Player p in PlayerDao.FindAll().OrderByDescending(s => s.Skills))
            {
                if (i < 5)
                {
                    var list = StatisticDao.FindAll().Where(s => { return(s.PlayerID == p.ID); }).ToList();
                    retList.Add(new Serialize(p, list));
                }
                i++;
            }

            return(Request.CreateResponse <List <Serialize> >(HttpStatusCode.OK, retList));
            //}
            //else
            //{
            //	return Request.CreateResponse(HttpStatusCode.Forbidden);
            //}
        }
コード例 #3
0
        public static void Initialize(TestContext context)
        {
            database = DalFactory.CreateDatabase();

            dao = DalFactory.CreateStatisticDao(database);

            Assert.IsNotNull(database);
        }
コード例 #4
0
        public void Update(Statistic team)
        {
            //if (Authentication.getInstance().isAuthenticateWithHeader(Request))
            //{
            IStatisticDao StatisticDao = DalFactory.CreateStatisticDao(database);

            StatisticDao.Update(team);
            //}
        }
コード例 #5
0
        public HttpResponseMessage FindByTimestamp(DateTime timestamp)
        {
            //if (Authentication.getInstance().isAuthenticateWithHeader(Request))
            //{
            IStatisticDao StatisticDao = DalFactory.CreateStatisticDao(database);

            return(Request.CreateResponse <IList <Statistic> >(HttpStatusCode.OK, StatisticDao.FindByDay(timestamp)));
            //}
            //else
            //{
            //	return Request.CreateResponse(HttpStatusCode.Forbidden);
            //}
        }
コード例 #6
0
        public HttpResponseMessage DeleteById(int id)
        {
            //if (Authentication.getInstance().isAuthenticateWithHeader(Request))
            //{
            IStatisticDao StatisticDao = DalFactory.CreateStatisticDao(database);

            return(Request.CreateResponse <bool>(HttpStatusCode.OK, StatisticDao.DeleteById(id)));
            //}
            //else
            //{
            //	return Request.CreateResponse(HttpStatusCode.Forbidden);
            //}
        }
コード例 #7
0
        public HttpResponseMessage Insert(Statistic team)
        {
            //if (Authentication.getInstance().isAuthenticateWithHeader(Request))
            //{
            IStatisticDao StatisticDao = DalFactory.CreateStatisticDao(database);

            return(Request.CreateResponse <int>(HttpStatusCode.OK, StatisticDao.Insert(team)));
            //}
            //else
            //{
            //	return Request.CreateResponse(HttpStatusCode.Forbidden);
            //}
        }
コード例 #8
0
        public void Insert()
        {
            IDatabase     db   = DalFactory.CreateDatabase();
            IPlayerDao    dao  = DalFactory.CreatePlayerDao(db);
            IStatisticDao sdao = DalFactory.CreateStatisticDao(db);

            var p = dao.FindByNickname("Alex");


            int a = sdao.FindAll().Count;

            BLStatistic.Insert(p.ID, 100);
            int b = sdao.FindAll().Count;

            Assert.IsTrue(a < b);
        }
コード例 #9
0
        public static void Decay()
        {
            IDatabase     database = DalFactory.CreateDatabase();
            IPlayerDao    pDao     = DalFactory.CreatePlayerDao(database);
            IStatisticDao sDao     = DalFactory.CreateStatisticDao(database);

            List <Player> pList = pDao.FindAll().Where(p =>
            {
                var statList = sDao.FindByPlayer(p.ID);
                if (!statList.Any())
                {
                    return(false);
                }
                var maxdate = statList.Max(s => s.Timestamp);
                return(DateTime.Now.AddDays(-60) < maxdate);
            }).ToList();

            foreach (Player p in pList)
            {
                p.Skills = (int)(p.Skills * 0.98);
                pDao.Update(p);
            }
        }