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)); }
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); //} }
public static void Initialize(TestContext context) { database = DalFactory.CreateDatabase(); dao = DalFactory.CreateStatisticDao(database); Assert.IsNotNull(database); }
public void Update(Statistic team) { //if (Authentication.getInstance().isAuthenticateWithHeader(Request)) //{ IStatisticDao StatisticDao = DalFactory.CreateStatisticDao(database); StatisticDao.Update(team); //} }
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); //} }
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); //} }
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); //} }
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); }
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); } }