public override GetPlayersOfUnfinishedChallanges Perform(GetPlayersOfUnfinishedChallanges query) { var yesterday = DateTimeGetter.GetDateTime().AddDays(-1); query.QueryResult = DbContext.Challenges .Where(x => x.Status == ChallengeStatus.InProgress && yesterday <= x.StartDate) .Select(x => x.Player) .ToList(); return(query); }
public override void Execute(BeginChallange command) { var challenge = DbContext.Challenges.SingleOrDefault(c => c.Id == command.Id); if (challenge == null) { return; } challenge.Status = ChallengeStatus.InProgress; challenge.StartDate = DateTimeGetter.GetDateTime(); DbContext.SaveChanges(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // Add framework services. services.AddCors(); services.AddMvc(); services.AddTmDbInMemory(Configuration); services.AddScoped <IUnitOfWork, UnitOfWork>(); services.AddScoped <IRepositoryFactory, UnitOfWork>(); services.AddScoped(typeof(IDbRepository <>), typeof(DbRepository <>)); services.AddScoped(typeof(IDbTmRepository <>), typeof(DbTmRepository <>)); services.AddScoped(typeof(IManyToManyRepository <>), typeof(ManyToManyRepository <>)); services.AddScoped <ITasksRepository, TasksRepository>(); services.AddScoped <ITaskService, TaskService>(); services.AddScoped <ITaskStateMachine, TaskStateMachine>(); services.AddSingleton <IDateTimeProvider, DefaultDateTimeProvider>(); services.AddSingleton <IGuidFactory, GuidFactory>(); DateTimeGetter.SetProvider(new DefaultDateTimeProvider()); }