// Test timer PRJ1 protected void Test() { using (var db = new DDLDataContext()) { var project = db.Projects.SingleOrDefault(x => x.ProjectID == 1); if (project == null) { throw new KeyNotFoundException(); } project.PopularPoint += 10; db.SaveChanges(); } }
// Caculate popular point protected void CaculatePopularProject() { using (var db = new DDLDataContext()) { // Get all project var projects = db.Projects.Where(x => x.IsExprired == false).ToList(); foreach (var project in projects) { if (project.PopularPoint != 0) { project.PopularPoint = project.PopularPoint / 2; } project.PopularPoint += project.PointOfTheDay; project.PointOfTheDay = 0; } //// Get all backing of the day //var backing = // db.Backings.Where( // x => // x.BackedDate.Year == DateTime.UtcNow.Year && x.BackedDate.Day == DateTime.UtcNow.Day && // x.BackedDate.Month == DateTime.UtcNow.Month).ToList(); //foreach (var back in backing) //{ // var project = projects.SingleOrDefault(x => x.ProjectID == back.ProjectID); // if (project == null) // { // throw new KeyNotFoundException(); // } // project.PopularPoint += 10; //} //// Get all comment of the day //var comment = // db.Comments.Where( // x => // x.CreatedDate.Year == DateTime.UtcNow.Year && x.CreatedDate.Day == DateTime.UtcNow.Day && // x.CreatedDate.Month == DateTime.UtcNow.Month).ToList(); //foreach (var cmt in comment) //{ // var project = projects.SingleOrDefault(x => x.ProjectID == cmt.ProjectID && cmt.UserID != x.CreatorID); // if (project == null) // { // throw new KeyNotFoundException(); // } // project.PopularPoint += 2; //} db.SaveChanges(); } }
// Check expire project protected void DetechExpiredProject() { using (var db = new DDLDataContext()) { var projects = db.Projects.Where(x => x.IsExprired == false && x.Status == DDLConstants.ProjectStatus.APPROVED).ToList(); foreach (var project in projects) { if (project.ExpireDate.Value.Year == DateTime.UtcNow.Year && project.ExpireDate.Value.Day == DateTime.UtcNow.Day && project.ExpireDate.Value.Month == DateTime.UtcNow.Month) { project.IsExprired = true; //project.Status = DDLConstants.ProjectStatus.EXPIRED; } db.SaveChanges(); } } }