コード例 #1
0
        public void AddSession_Added_NotFail_Test()
        {
            var context = new MyEventsContext();
            int eventDefinitionId = context.EventDefinitions.FirstOrDefault().EventDefinitionId;

            int expected = context.Sessions.Count() + 1;

            ISessionRepository target = new SessionRepository();

            Session session = new Session();
            session.EventDefinitionId = eventDefinitionId;
            session.Title = Guid.NewGuid().ToString();
            session.Description = Guid.NewGuid().ToString();
            session.Speaker = Guid.NewGuid().ToString();
            session.Biography = Guid.NewGuid().ToString();
            session.TwitterAccount = Guid.NewGuid().ToString();
            session.StartTime = DateTime.Now;
            session.TimeZoneOffset = 2;
            session.Duration = 60;

            target.Add(session);

            int actual = context.Sessions.Count();

            Assert.AreEqual(expected, actual);
        }
コード例 #2
0
		public Promise Start(string sessionId)
		{
			Promise promise = new Promise();

			try
			{
				Uri serverUri = new Uri(appSettings.ServerURI, UriKind.RelativeOrAbsolute);
				Uri restUri = new Uri(serverUri, "rest/");

				SessionRepository repo = new SessionRepository(restUri);
				if (repo == null)
				{
					throw new Exception("SessionRepository is not initialized.");
				}
							
				repo.GetByKey(sessionId, (response) =>
				{
					if (response.Success)
					{
						promise.Resolve(response.Item);
					}
					else
					{
						promise.Reject(new Exception(response.Error));
					}
				});                   
			}
			catch (Exception e)
			{
				promise.Reject(e);
			}

			return promise;
		}
コード例 #3
0
ファイル: DataService.cs プロジェクト: mehuledu/ndc
        public DataService()
        {
            ConferenceStart = DateTime.Parse("2013/11/04");
            ConferenceEnd = DateTime.Parse("2013/11/06");

            TopicRepository = new TopicRepository(LoadJsonArray("topics.json"));
            SessionRepository = new SessionRepository(LoadJsonArray("sessions.json"));
            SpeakerRepository = new SpeakerRepository(LoadJsonArray("speakers.json"));
            SessionTopicRepository = new SessionTopicRepository(LoadJsonArray("sessiontopics.json"));
        }
コード例 #4
0
ファイル: ApiModule.cs プロジェクト: ritasker/ZorkSms
        public ApiModule(SmsRepository smsRepository, SessionRepository sessionRepository) : base("/api")
        {
            _sessionRepository = sessionRepository;
            _smsRepository = smsRepository;

            Post["/ReceiveSms"] = o => ReceiveSms();

            Get["/TestReceive"] = o => { return this.View["TestReceive"]; };
            Post["/TestReceive"] = o => { return TestReceive().Result; };
        }
コード例 #5
0
        public ModelContext()
            : base("CashManager")
        {
            Configuration.ValidateOnSaveEnabled = false;

            OrderRepository = new OrderRepository();
            SessionRepository = new SessionRepository();
            TransactionRepository = new TransactionRepository();
            UserRepository = new UserRepository();
        }
コード例 #6
0
ファイル: Repositories.cs プロジェクト: usmanghani/Quantae
 public static void Init(DataStore dataStore)
 {
     Sentences = new SentenceRepository(dataStore, "SentenceText");
     Vocabulary = new VocabRepository(dataStore, "Text");
     GrammarEntries = new GrammarEntryRepository(dataStore, "Text");
     GrammarRoles = new GrammarRolesRepository(dataStore, "RoleName");
     Users = new UserRepository(dataStore, "UserID", "Email");
     Topics = new TopicRepository(dataStore, "Index", "ToicName");
     Sessions = new SessionRepository(dataStore, "UserID");
 }
コード例 #7
0
        public void GetSession_Call_NotFail_Test()
        {
            var context   = new MyEventsContext();
            int sessionId = context.Sessions.FirstOrDefault().SessionId;

            ISessionRepository target = new SessionRepository();

            Session result = target.Get(sessionId);

            Assert.IsNotNull(result);
            Assert.AreEqual(sessionId, result.SessionId);
        }
コード例 #8
0
        public ActionResult MrshdyAfter(evaluation_murshadee_after ecpp)
        {
            var repo = new EvaluationMurshadeeAfterRepository();

            ecpp.Rowld     = Guid.NewGuid();
            ecpp.CreatedAt = DateTime.Now;
            repo.Post(ecpp);
            var sessionrepo = new SessionRepository();

            sessionrepo.SetPostEvaluationStatus(ecpp.StudentId, ecpp.SessionId);
            return(RedirectToAction("Index", "Session"));
        }
コード例 #9
0
        public ActionResult SYCPreP2(evaluation_syc_pre_part2 ecpp)
        {
            var repo = new EvaluationSycPrePart2Repository();

            ecpp.Rowld     = Guid.NewGuid();
            ecpp.CreatedAt = DateTime.Now;
            repo.Post(ecpp);
            var sessionrepo = new SessionRepository();

            sessionrepo.SetPreEvaluationStatus(ecpp.StudentId, ecpp.SessionId);
            return(RedirectToAction("Index", "Session"));
        }
コード例 #10
0
        public ActionResult PFPost(evaluation_pf_post ecpp)
        {
            var repo = new EvaluationPFPostRepository();

            ecpp.RowId     = Guid.NewGuid();
            ecpp.CreatedAt = DateTime.Now;
            repo.Post(ecpp);
            var sessionrepo = new SessionRepository();

            sessionrepo.SetPostEvaluationStatus(ecpp.StudentId, ecpp.SessionId);
            return(RedirectToAction("Index", "Session"));
        }
コード例 #11
0
        public ActionResult CPPre(evaluation_cp_pre ecpp)
        {
            var repo = new EvaluationCpPreRepository();

            ecpp.RowId    = Guid.NewGuid();
            ecpp.CreateAt = DateTime.Now;
            repo.Post(ecpp);
            var sessionrepo = new SessionRepository();

            sessionrepo.SetPreEvaluationStatus(ecpp.StudentId, ecpp.SessionId);
            return(RedirectToAction("Index", "Session"));
        }
コード例 #12
0
 public SqlQueriesController(SqlQueryReader sqlQueryReader,
                             SqlRunner runner,
                             ResultRepository resultRepository,
                             SessionRepository sessionRepository,
                             Tabularizer tabularizer)
 {
     _sqlQueryReader    = sqlQueryReader;
     _runner            = runner;
     _resultRepository  = resultRepository;
     _sessionRepository = sessionRepository;
     _tabularizer       = tabularizer;
 }
コード例 #13
0
        public void Should_Throw_An_ArgumentException_When_UnxistentId_Provided()
        {
            var options = new DbContextOptionsBuilder <RegistrationContext>()
                          .UseInMemoryDatabase(databaseName: MethodBase.GetCurrentMethod().Name)
                          .Options;

            using (var context = new RegistrationContext(options))
            {
                IRSSessionRepository sessionRepository = new SessionRepository(context);
                Assert.ThrowsException <ArgumentException>(() => sessionRepository.GetById(1));
            }
        }
コード例 #14
0
        public async Task DeleteAsync_given_non_existing_sessionId_returns_false()
        {
            using (var connection = await this.CreateConnectionAsync())
                using (var context = await this.CreateContextAsync(connection))
                {
                    var repository = new SessionRepository(context);

                    var deleted = await repository.DeleteAsync(42);

                    Assert.False(deleted);
                }
        }
コード例 #15
0
        public async Task IntegrationTestGetSession_WithInvalidSessionId()
        {
            // Arrange
            SessionRepository repository = new SessionRepository(DevelopmentStorageAccountConnectionString);
            Guid invalidGuid             = new Guid("3286C8E6-B510-4F7F-AAE0-9EF827459E7E");

            // Act
            ISession result = await repository.GetSession(invalidGuid);

            // Assert
            Assert.IsNull(result);
        }
コード例 #16
0
ファイル: WorldController.cs プロジェクト: StephenE/DevoLAN
        public async Task <IEnumerable <ICombat> > GetCombat(Guid sessionId)
        {
            ISession session = await SessionRepository.GetSessionOrThrow(sessionId)
                               .IsUserIdJoinedOrThrow(NationRepository, User.Identity.GetUserId());

            IEnumerable <ICombat> combatData = await WorldRepository.GetCombat(session.GameId, session.Round);

            return(from combat in combatData
                   where IsStillValid(session, combat)
                   orderby combat.ResolutionType ascending
                   select new Combat(combat));
        }
コード例 #17
0
        public async Task IntegrationTestAddArmyToCombat()
        {
            // Arrange
            WorldRepository  repository         = new WorldRepository(DevelopmentStorageAccountConnectionString);
            Guid             combatId           = new Guid("0DAAF6DD-E1D6-42BA-B3ED-749BB7652C8E");
            Guid             attackingRegionId  = new Guid("5EA3D204-63EA-4683-913E-C5C3609BD893");
            Guid             attacking2RegionId = new Guid("E0675161-4192-4C33-B8BB-3B6D763725E2");
            Guid             attacking3RegionId = new Guid("CA563328-5743-4EC0-AA39-D7978DE44872");
            Guid             defendingRegionId  = new Guid("6DC3039A-CC79-4CAC-B7CE-37E1B1565A6C");
            CombatTableEntry tableEntry         = new CombatTableEntry(SessionId, 1, combatId, CombatType.MassInvasion);

            tableEntry.SetCombatArmy(new List <ICombatArmy>
            {
                new CombatArmy(attackingRegionId, "AttackingUser", Core.CombatArmyMode.Attacking, 5),
                new CombatArmy(defendingRegionId, "DefendingUser", Core.CombatArmyMode.Defending, 4)
            });

            CloudTable testTable = SessionRepository.GetTableForSessionData(TableClient, SessionId);

            testTable.CreateIfNotExists();
            TableOperation insertOperation = TableOperation.Insert(tableEntry);
            await testTable.ExecuteAsync(insertOperation);

            // Act
            using (BatchOperationHandle batchOperation = new BatchOperationHandle(testTable))
            {
                repository.AddArmyToCombat(batchOperation, tableEntry, new List <ICombatArmy>
                {
                    new CombatArmy(attacking2RegionId, "AttackingUser", Core.CombatArmyMode.Attacking, 6),
                    new CombatArmy(attacking3RegionId, "AttackingUser2", Core.CombatArmyMode.Attacking, 3)
                });
            }

            // Assert
            TableOperation operation = TableOperation.Retrieve <CombatTableEntry>(SessionId.ToString(), "Combat_" + combatId.ToString());
            TableResult    result    = await testTable.ExecuteAsync(operation);

            Assert.IsNotNull(result.Result);
            Assert.IsInstanceOfType(result.Result, typeof(CombatTableEntry));
            CombatTableEntry resultStronglyTyped = result.Result as CombatTableEntry;

            Assert.AreEqual(SessionId, resultStronglyTyped.SessionId);
            Assert.AreEqual(combatId, resultStronglyTyped.CombatId);
            Assert.AreEqual(1, resultStronglyTyped.Round);
            Assert.AreEqual(CombatType.MassInvasion, resultStronglyTyped.ResolutionType);
            Assert.AreEqual(4, resultStronglyTyped.InvolvedArmies.Count());

            AssertCombat.IsAttacking(attackingRegionId, 5, "AttackingUser", resultStronglyTyped);
            AssertCombat.IsAttacking(attacking2RegionId, 6, "AttackingUser", resultStronglyTyped);
            AssertCombat.IsAttacking(attacking3RegionId, 3, "AttackingUser2", resultStronglyTyped);
            AssertCombat.IsDefending(defendingRegionId, 4, "DefendingUser", resultStronglyTyped);
        }
コード例 #18
0
        public ActionResult MarkCompleted(session session)
        {
            var cu          = Session["user"] as ContextUser;
            var sessionRepo = new SessionRepository();
            var oSession    = sessionRepo.Get(session.Id);

            if (Request.Form["SubmitButton"] == "Upload")
            {
                sessionRepo.RemoveSessionPhoto(session.Id);
                foreach (var item in session.EvaluationImageLink.Split(',').Where(x => !string.IsNullOrWhiteSpace(x)))
                {
                    oSession.session_evaluationform_photo.Add(new session_evaluationform_photo {
                        FilePath = item, FileExtension = Path.GetExtension(item)
                    });
                }
                foreach (var item in session.SessionImageLink.Split(',').Where(x => !string.IsNullOrWhiteSpace(x)))
                {
                    oSession.session_photo.Add(new session_photo {
                        FilePath = item, FileExtension = Path.GetExtension(item)
                    });
                }
            }
            else if (Request.Form["SubmitButton"] == "fillvolunteerevaluation")
            {
                int corId = new CoordinatorRepository().GetByUserId(cu.OUser.Id).Id;
                return(RedirectToAction("VolenteerForm", "EvaluationForm", new { sessionId = oSession.Id, volId = oSession.volunteer_profile.Id, corId = corId }));
            }
            else
            {
                oSession.MarkedCompletedByCoordinator = true;

                var volEmail              = oSession.volunteer_profile.VolunteerEmail;
                var bogusController       = Util.CreateController <EmailTemplateController>();
                EmailTemplateModel emodel =
                    new EmailTemplateModel
                {
                    Title           = "Notification: coordinator session marked as completed.",
                    CoordinatorName = oSession.school.coordinator_profile.FirstOrDefault().CoordinatorName,
                    SessionTitle    = oSession.ProgramName,
                    VolunteerName   = oSession.volunteer_profile.VolunteerName,
                    User            = oSession.school.user.FirstName
                };
                string body =
                    Util.RenderViewToString(bogusController.ControllerContext, "CoordinatorMarkCompleted", emodel);
                EmailSender.SendSupportEmail(body, volEmail);

                var adminEmail = new AccountRepository().Get(oSession.CreatedBy).Email;
                EmailSender.SendSupportEmail(body, adminEmail);
            }
            sessionRepo.Put(oSession.Id, oSession);
            return(RedirectToAction("Index"));
        }
コード例 #19
0
        public async Task IntegrationTestGetCombatByType()
        {
            // Arrange
            WorldRepository  repository        = new WorldRepository(DevelopmentStorageAccountConnectionString);
            Guid             combatId          = new Guid("B75CFB8A-727A-46C1-A952-BF2B1AFF9AD8");
            Guid             secondCombatId    = new Guid("2F366A82-A99C-4A83-BF0E-FFF8D87D94A6");
            Guid             attackingRegionId = new Guid("5EA3D204-63EA-4683-913E-C5C3609BD893");
            Guid             defendingRegionId = new Guid("6DC3039A-CC79-4CAC-B7CE-37E1B1565A6C");
            CombatTableEntry tableEntry        = new CombatTableEntry(SessionId, 1, combatId, CombatType.Invasion);

            tableEntry.SetCombatArmy(new List <ICombatArmy>
            {
                new CombatArmy(attackingRegionId, "AttackingUser", Core.CombatArmyMode.Attacking, 5),
                new CombatArmy(defendingRegionId, "DefendingUser", Core.CombatArmyMode.Defending, 4)
            });
            CombatTableEntry secondTableEntry = new CombatTableEntry(SessionId, 1, secondCombatId, CombatType.SpoilsOfWar);

            secondTableEntry.SetCombatArmy(new List <ICombatArmy>
            {
                new CombatArmy(attackingRegionId, "AttackingUser", Core.CombatArmyMode.Attacking, 5),
                new CombatArmy(defendingRegionId, "DefendingUser", Core.CombatArmyMode.Defending, 4)
            });

            CloudTable testTable = SessionRepository.GetTableForSessionData(TableClient, SessionId);

            testTable.CreateIfNotExists();
            TableOperation insertOperation = TableOperation.Insert(tableEntry);
            await testTable.ExecuteAsync(insertOperation);

            insertOperation = TableOperation.Insert(secondTableEntry);
            await testTable.ExecuteAsync(insertOperation);

            CombatTableEntry thirdTableEntry = new CombatTableEntry(SessionId, 2, Guid.NewGuid(), CombatType.SpoilsOfWar);

            insertOperation = TableOperation.Insert(thirdTableEntry);
            await testTable.ExecuteAsync(insertOperation);

            // Act
            var results = await repository.GetCombat(SessionId, 1, CombatType.SpoilsOfWar);

            // Assert
            Assert.IsNotNull(results);
            Assert.AreEqual(1, results.Count());

            ICombat result = results.Where(combat => combat.CombatId == combatId).FirstOrDefault();

            Assert.IsNull(result);

            result = results.Where(combat => combat.CombatId == secondCombatId).FirstOrDefault();
            Assert.IsNotNull(result);
            Assert.AreEqual(CombatType.SpoilsOfWar, result.ResolutionType);
        }
コード例 #20
0
        static void Main(string[] args)
        {
            HappContext        dbContext         = new HappContext();
            IEMRRepository     eMRRepository     = new EMRRepository(dbContext);
            ISessionRepository sessionRepository = new SessionRepository(dbContext);
            EMR eMR = new EMR()
            {
                ID = Guid.NewGuid(), Ppubkey = "P@u0d?#1N3z"
            };

            eMRRepository.Add(eMR);
            dbContext.SaveChanges();
        }
コード例 #21
0
 public ActionResult Logout()
 {
     try
     {
         string token = GetSessionFromHeader();
         SessionRepository.RemoveSession(token);
         return(Ok());
     }
     catch (Exception e)
     {
         return(BadRequest($"Se dio un error al procesar la solicitud: {e.Message}"));
     }
 }
コード例 #22
0
        public void GetSession_CalculateScore_Test()
        {
            var    context  = new MyEventsContext();
            var    session  = context.Sessions.Include("SessionRegisteredUsers").FirstOrDefault(q => q.SessionRegisteredUsers.Any());
            double expected = session.SessionRegisteredUsers.Where(sr => sr.Rated).Average(sr => sr.Score);

            ISessionRepository target = new SessionRepository();

            Session result = target.Get(session.SessionId);

            Assert.IsNotNull(result);
            Assert.AreEqual(expected, result.Score);
        }
コード例 #23
0
        public void SignOut_CorrectData_Success(int _clientId)
        {
            var testSessionToken = SessionRepository.StartNewSession(_clientId);

            var signOutQuery = new SignOutQuery
            {
            };

            var handler = new SignOutQueryHandler();
            var result  = (SuccessInfoDto)handler.Handle(signOutQuery);

            Assert.IsTrue(result.isSuccess);
        }
コード例 #24
0
        public override void Handle(EndConnectionRequest request)
        {
            if (!IsRequestValid(request.SessionId))
            {
                return;
            }

            SessionRepository.RemoveSession(request.SessionId);

            connectionEndedCallback(request.SessionId);

            Socket.SendNetworkMsg(new EndConnectionResponse());
        }
コード例 #25
0
ファイル: ProxyStore.cs プロジェクト: Possum-Labs/Slipka
 private void PersistSession(Session session)
 {
     try
     {
         var record = LastUpdated[session.Id];
         record.LastUpdate = DateTime.Now;
         SessionRepository.UpdateSession(session);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
コード例 #26
0
 public SessionController(
     ILogger <SessionController> logger,
     IConfiguration config,
     SessionRepository sessions,
     IUserRepository users,
     GameRepository games)
 {
     _logger   = logger;
     _botPlay  = config.GetValue("Simple-Bot", false);
     _sessions = sessions;
     _users    = users;
     _games    = games;
 }
コード例 #27
0
        public static void ClassInit(TestContext context)
        {
            CloudStorageEmulatorShepherd shepherd = new CloudStorageEmulatorShepherd();

            shepherd.Start();

            StorageAccount = CloudStorageAccount.Parse(DevelopmentStorageAccountConnectionString);
            TableClient    = StorageAccount.CreateCloudTableClient();

            CloudTable testTable = SessionRepository.GetTableForSessionData(TableClient, SessionId);

            testTable.DeleteIfExists();
        }
コード例 #28
0
        public void Setup()
        {
            var connection = DbConnectionFactory.CreatePersistent(Guid.NewGuid().ToString());

            _context    = new FakeDbContext(connection);
            _repository = new SessionRepository(_context);
            _session    = ObjectMother.GetDefaultSession();

            //Seed
            _sessionBase = ObjectMother.GetDefaultSession();
            _context.Sessions.Add(_sessionBase);
            _context.SaveChanges();
        }
コード例 #29
0
        public void DeleteSession_NoExists_NotFail_Test()
        {
            var context = new MyEventsContext();
            var session = context.Sessions.FirstOrDefault();
            int expected = context.Sessions.Count();

            ISessionRepository target = new SessionRepository();
            target.Delete(0);

            int actual = context.Sessions.Count();

            Assert.AreEqual(expected, actual);
        }
コード例 #30
0
        public void SetUp()
        {
            var connection = DbConnectionFactory.CreatePersistent(Guid.NewGuid().ToString());

            Context     = new FakeDbContext(connection);
            _repository = new SessionRepository(Context);
            _session    = ObjectMother.sessionToPersist;

            _sessionSeed = ObjectMother.sessionToPersist;

            Context.Sessions.Add(_sessionSeed);
            Context.SaveChanges();
        }
コード例 #31
0
        public async Task IntegrationTestCreateRegion()
        {
            // Arrange
            RegionRepository repository       = new RegionRepository(DevelopmentStorageAccountConnectionString, String.Empty);
            Guid             dummySessionId   = new Guid("74720766-452A-40AD-8A61-FEF07E8573C9");
            Guid             dummyRegionId    = new Guid("024D1E45-EF34-4AB1-840D-79229CCDE8C3");
            Guid             dummyContinentId = new Guid("DE167712-0CE6-455C-83EA-CB2A6936F1BE");
            List <Guid>      dummyConnections = new List <Guid> {
                new Guid("0533203F-13F2-4863-B528-17F53D279E19"), new Guid("4A9779D0-0727-4AD9-AD66-17AE9AF9BE02")
            };
            var dataTable = TableClient.SetupSessionDataTable(dummySessionId);

            // Act
            using (IBatchOperationHandle batchOperation = new BatchOperationHandle(SessionRepository.GetTableForSessionData(TableClient, dummySessionId)))
            {
                repository.CreateRegion(batchOperation, dummySessionId, dummyRegionId, dummyContinentId, "DummyRegion", dummyConnections, 3);
            }

            // Assert
            TableOperation operation = TableOperation.Retrieve <RegionTableEntry>(dummySessionId.ToString(), "Region_" + dummyRegionId.ToString());
            TableResult    result    = await dataTable.ExecuteAsync(operation);

            Assert.IsNotNull(result.Result);
            Assert.IsInstanceOfType(result.Result, typeof(RegionTableEntry));
            RegionTableEntry resultStronglyTyped = result.Result as RegionTableEntry;

            Assert.AreEqual(dummySessionId, resultStronglyTyped.SessionId);
            Assert.AreEqual(dummyRegionId, resultStronglyTyped.RegionId);
            Assert.AreEqual(dummyContinentId, resultStronglyTyped.ContinentId);
            Assert.AreEqual("DummyRegion", resultStronglyTyped.Name);
            Assert.AreEqual(String.Empty, resultStronglyTyped.OwnerId);
            Assert.AreEqual(3U, resultStronglyTyped.CardValue);
            Assert.AreEqual(0, resultStronglyTyped.StoredTroopCount);
            Assert.IsTrue(resultStronglyTyped.ETag.Length > 0);
            Assert.IsTrue(resultStronglyTyped.ConnectedRegions.Contains(dummyConnections[0]));

            TableOperation cardOperation = TableOperation.Retrieve <CardTableEntry>(dummySessionId.ToString(), "Card_" + dummyRegionId.ToString());

            result = await dataTable.ExecuteAsync(cardOperation);

            Assert.IsNotNull(result.Result);
            Assert.IsInstanceOfType(result.Result, typeof(CardTableEntry));
            CardTableEntry cardStronglyTyped = result.Result as CardTableEntry;

            Assert.AreEqual(dummySessionId, cardStronglyTyped.SessionId);
            Assert.AreEqual(dummyRegionId, cardStronglyTyped.RegionId);
            Assert.AreEqual(3U, cardStronglyTyped.Value);
            Assert.AreEqual(String.Empty, cardStronglyTyped.OwnerId);
            Assert.AreEqual(CardTableEntry.State.Unowned, cardStronglyTyped.OwnerState);
        }
コード例 #32
0
ファイル: Startup.cs プロジェクト: tipejn/DatingApp
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddScoped <DatingRepository>(sp => SessionRepository.GetDatingRepository(sp));
     services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
     services.AddTransient <IPersonValidator, AgeValidator>();
     services.AddTransient <IPersonValidator, HeightValidator>();
     services.AddTransient <IPersonValidator, EyesColorValidator>();
     services.AddMvc(options =>
     {
         options.ModelBindingMessageProvider.SetValueMustNotBeNullAccessor(_ => "Nieprawidłowa wartość");
     });
     services.AddMemoryCache();
     services.AddSession();
 }
コード例 #33
0
        public ControllerAzure(String developmentStorageAccountConnectionString, String worldDefinitionPath, String userId)
        {
            OwnerId = userId;

            UserRepository = new DummyUserRepository();

            AzureCommandQueue      = new CommandQueue(developmentStorageAccountConnectionString);
            AzureNationRepository  = new NationRepository(developmentStorageAccountConnectionString);
            AzureRegionRepository  = new RegionRepository(developmentStorageAccountConnectionString, worldDefinitionPath);
            AzureSessionRepository = new SessionRepository(developmentStorageAccountConnectionString);
            AzureWorldRepository   = new WorldRepository(developmentStorageAccountConnectionString);

            CreateControllers();
        }
コード例 #34
0
        public void DeleteSession_NoExists_NotFail_Test()
        {
            var context  = new MyEventsContext();
            var session  = context.Sessions.FirstOrDefault();
            int expected = context.Sessions.Count();

            ISessionRepository target = new SessionRepository();

            target.Delete(0);

            int actual = context.Sessions.Count();

            Assert.AreEqual(expected, actual);
        }
コード例 #35
0
        public void GetAllSessions_Call_NotFail_Test()
        {
            var context           = new MyEventsContext();
            int eventDefinitionId = context.Sessions.FirstOrDefault().EventDefinitionId;

            int expectedCount = context.Sessions.Count(q => q.EventDefinitionId == eventDefinitionId);

            ISessionRepository target = new SessionRepository();

            IEnumerable <Session> results = target.GetAll(eventDefinitionId);

            Assert.IsNotNull(results);
            Assert.AreEqual(expectedCount, results.Count());
        }
コード例 #36
0
 public UnitOfWork(Model1 dbContext)
 {
     _dbContext                 = dbContext;
     StudentRepository          = new StudentRepository(_dbContext);
     TeacherRepository          = new TeacherRepository(_dbContext);
     PrincipalRepository        = new PrincipalRepository(_dbContext);
     UserRepository             = new UserRepository(_dbContext);
     School_SubjectsRepository  = new School_SubjectsRepository(_dbContext);
     SessionRepository          = new SessionRepository(_dbContext);
     Teachers_ClassesRepository = new Teachers_ClassesRepository(_dbContext);
     dClassRepository           = new ClassRepository(_dbContext);
     SubjectsRepository         = new SubjectsRepository(_dbContext);
     //add other repositories here
 }
コード例 #37
0
        public async Task CreateAsync_given_dto_returns_created_Session()
        {
            using (var connection = await this.CreateConnectionAsync())
                using (var context = await this.CreateContextAsync(connection))
                {
                    var repository = new SessionRepository(context);
                    var dto        = this.CreateDummySessionDTO();

                    var session = await repository.CreateAsync(dto);

                    Assert.Equal(1, session.Id);
                    Assert.Equal("A1B2C3D", session.SessionKey);
                }
        }
コード例 #38
0
ファイル: HomeController.cs プロジェクト: hudl/black-mesa
        public ContentResult Config()
        {
            if (HttpContext.Request.Cookies[CookieAuthenticatedAttribute.CookieName] == null)
            {
                return null;
            }

            var authCookie = HttpContext.Request.Cookies[CookieAuthenticatedAttribute.CookieName].Value;
            var displayName = new SessionRepository().GetById(new ObjectId(authCookie)).DisplayName;
            return new ContentResult
            {
                Content = @"(function(blackmesa){blackmesa.username='******';})(window.BlackMesa);",
                ContentType = "text/javascript"
            };
        }
コード例 #39
0
ファイル: AddTestData.cs プロジェクト: namesecured/MapReduce
        private void GenerateSessions(DateTime startDate, DateTime endDate, int maxSessions)
        {
            var date = startDate;

            ISessionRepository repository = new SessionRepository();
            while (date <= endDate)
            {
                for (int i = 0; i < maxSessions; i++)
                {
                    var session = this.GenerateSession(date);
                    repository.Add(session);
                }
                date = date.AddDays(1);
            }
        }
コード例 #40
0
        public void GetAllSessions_Call_CalculateScore_Test()
        {
            var context = new MyEventsContext();
            int eventDefinitionId = context.Sessions.FirstOrDefault().EventDefinitionId;

            int expectedCount = context.Sessions.Count(q => q.EventDefinitionId == eventDefinitionId);

            ISessionRepository target = new SessionRepository();

            IEnumerable<Session> results = target.GetAll(eventDefinitionId);

            Assert.IsNotNull(results);
            Assert.AreEqual(expectedCount, results.Count());

            foreach (var session in results)
                ValidateScore(session.SessionId, session.Score);
        }
コード例 #41
0
 public static void Initialize()
 {
     Users = new UserRepository();
     Sessions = new SessionRepository();
 }
コード例 #42
0
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            //Password = txtPassword.Password;

            if (string.IsNullOrEmpty(UserName))
            {
                MessageBox.Show("Enter user name");
                return;
            }
            if (string.IsNullOrEmpty(Password))
            {
                MessageBox.Show("Enter user password");
                return;
            }

            UsersRepository _userRepo = new UsersRepository();
            Users _user = _userRepo.FindByQuery(" username = '******' AND Password = '******'").FirstOrDefault();

            if (_user != null)
            {
                UsersDetail _userDetail = new UsersDetailRepository().FindByUserID(_user.UserID);

                Utilities.UserSession.DisplayName = _userDetail.FullName;
                Utilities.UserSession.UserName = _user.UserName;
                Utilities.UserSession.UserID = _user.UserID;
                Utilities.UserSession.Password = _user.Password;
                Utilities.UserSession.RoleID = _user.RoleID;
                Utilities.UserSession.SchoolName = "So-Business School Management System";

                var session= new SessionRepository().GetAll().Where(p => p.isActive = true).FirstOrDefault();

                Utilities.UserSession.SessionID = session != null ? session.SessionID : 0;
                
                MainWindow page = new MainWindow();
                page.Show();
                this.Close();
            }
            else
            {
                MessageBox.Show("User Not Found");
            }

        }
コード例 #43
0
        public void A_FinisedEvaSession_creates_a_new_Session_in_the_database()
        {
            var bootStrapper = new BootStrapper();
            bootStrapper.StartServices();
            var serviceEvents = bootStrapper.GetService<IServiceEvents>();
            //1.- Create message
            var aggr = GenerateRandomAggregate();
            var message = GenerateMessage(aggr);
            //2.- Emit message
            serviceEvents.AddIncommingEvent(new IncommingEvent { @event = message });
            //3.- Load the saved country
            var repository = new SessionRepository(_configuration.TestServer);
            var session = repository.Get(aggr.Id);
            //4.- Check equality
            Assert.Equal(aggr.Id, session.Id);
            Assert.Equal(aggr.CommissionId, session.CommissionId);
            Assert.Equal(aggr.EndTime.Value.Second, session.EndTime.Value.Second);
            Assert.Equal(aggr.InitialTime.Value.Second, session.InitialTime.Value.Second);
            Assert.Equal(aggr.InvoiceId, session.InvoiceId);
            Assert.Equal(aggr.InterpretationDone, session.InterpretationDone);
            Assert.Equal(aggr.SignedDate.Value.Second, session.SignedDate.Value.Second);
            Assert.Equal(aggr.GuardianId, session.GuardianId);
            Assert.Equal(aggr.PartnerId, session.PartnerId);
            Assert.Equal(aggr.PatientId, session.PatientId);
            Assert.Equal(aggr.ServiceLevelId, session.ServiceLevelId);
            Assert.Equal(aggr.ServiceId, session.ServiceId);
            Assert.Equal(aggr.MediaId, session.MediaId);
            Assert.Equal(aggr.MachineId, session.MachineId);
            Assert.Equal(aggr.PayableId, session.PayableId);
            Assert.Equal(aggr.CommissionId, session.CommissionId);
            Assert.Equal(aggr.TimeStamp.Second, session.TimeStamp.Second);

            var appoinment = session.Appointment.First();
            Assert.Equal(appoinment.Id, aggr.Appointment.First().Id);
            Assert.Equal(appoinment.InitialTime.Second, aggr.Appointment.First().InitialTime.Second);
            Assert.Equal(appoinment.FinalTime.Second, aggr.Appointment.First().FinalTime.Second);
            Assert.Equal(appoinment.MachineId, aggr.Appointment.First().MachineId);
            Assert.Equal(appoinment.MediaId, aggr.Appointment.First().MediaId);
            Assert.Equal(appoinment.PartnerId, aggr.Appointment.First().PartnerId);
            Assert.Equal(appoinment.PatientId, aggr.Appointment.First().PatientId);
            Assert.Equal(appoinment.PayableId, aggr.Appointment.First().PayableId);
            Assert.Equal(appoinment.ServiceId, aggr.Appointment.First().ServiceId);
            Assert.Equal(appoinment.ServiceLevelId, aggr.Appointment.First().ServiceLevelId);
            Assert.Equal(appoinment.ServiceTypeId, aggr.Appointment.First().ServiceTypeId);
            Assert.Equal(appoinment.SessionId, aggr.Appointment.First().SessionId);
            Assert.Equal(appoinment.StatusType, aggr.Appointment.First().StatusType);
            Assert.Equal(appoinment.TimeZoneId, aggr.Appointment.First().TimeZoneId);
            Assert.Equal(appoinment.TimeStamp.Second, aggr.Appointment.First().TimeStamp.Second);

            var sessionDevice = session.SessionDevice.First();
            Assert.Equal(sessionDevice.Id, aggr.SessionDevice.First().Id);
            Assert.Equal(sessionDevice.DeviceGroup, aggr.SessionDevice.First().DeviceGroup);
            Assert.Equal(sessionDevice.DeviceId, aggr.SessionDevice.First().DeviceId);
            Assert.Equal(sessionDevice.SapCode, aggr.SessionDevice.First().SapCode);
            Assert.Equal(sessionDevice.SerialNumber, aggr.SessionDevice.First().SerialNumber);
            Assert.Equal(sessionDevice.SessionId, aggr.SessionDevice.First().SessionId);
            Assert.Equal(sessionDevice.TimeStamp.Second, aggr.SessionDevice.First().TimeStamp.Second);

            var diagnosis = session.Diagnosis.First();
            Assert.Equal(diagnosis.Id, aggr.Diagnosis.First().Id);
            Assert.Equal(diagnosis.Appraisal, aggr.Diagnosis.First().Appraisal);
            Assert.Equal(diagnosis.Name, aggr.Diagnosis.First().Name);
            Assert.Equal(diagnosis.SessionId, aggr.Diagnosis.First().SessionId);
            Assert.Equal(diagnosis.TimeStamp.Second, aggr.Diagnosis.First().TimeStamp.Second);
        }
コード例 #44
0
        public void GetAllSessions_Call_NotFail_Test()
        {
            var context = new MyEventsContext();
            int eventDefinitionId = context.Sessions.FirstOrDefault().EventDefinitionId;

            int expectedCount = context.Sessions.Count(q => q.EventDefinitionId == eventDefinitionId);

            ISessionRepository target = new SessionRepository();

            IEnumerable<Session> results = target.GetAll(eventDefinitionId);

            Assert.IsNotNull(results);
            Assert.AreEqual(expectedCount, results.Count());
        }
コード例 #45
0
 public SessionFactoryManager()
 {
     _sessionsRepository = new SessionRepository<ISessionFactory>();
 }
コード例 #46
0
 public SessionController(SessionRepository repository)
 {
     _repository = repository;
 }
コード例 #47
0
        public void UpdateSession_Updated_NotFail_Test()
        {
            var context = new MyEventsContext();
            var sessionToUpdate = context.Sessions.FirstOrDefault();

            int expected = context.Sessions.Count() + 1;

            ISessionRepository target = new SessionRepository();

            sessionToUpdate.Title = Guid.NewGuid().ToString();
            target.Update(sessionToUpdate);

            var sessionUpdated = context.Sessions.FirstOrDefault(q => q.SessionId == sessionToUpdate.SessionId);

            Assert.AreEqual(sessionToUpdate.Title, sessionUpdated.Title);
        }
コード例 #48
0
        public void GetSession_Call_NotFail_Test()
        {
            var context = new MyEventsContext();
            int sessionId = context.Sessions.FirstOrDefault().SessionId;

            ISessionRepository target = new SessionRepository();

            Session result = target.Get(sessionId);

            Assert.IsNotNull(result);
            Assert.AreEqual(sessionId, result.SessionId);
        }
コード例 #49
0
        public void GetSession_CalculateScore_Test()
        {
            var context = new MyEventsContext();
            var session = context.Sessions.Include("SessionRegisteredUsers").FirstOrDefault(q => q.SessionRegisteredUsers.Any());
            double expected = session.SessionRegisteredUsers.Where(sr => sr.Rated).Average(sr => sr.Score);

            ISessionRepository target = new SessionRepository();

            Session result = target.Get(session.SessionId);

            Assert.IsNotNull(result);
            Assert.AreEqual(expected, result.Score);
        }
コード例 #50
0
        public void GetSessionOrganizerId_Call_GetResult_Test()
        {
            var context = new MyEventsContext();
            var session = context.Sessions.Include("EventDefinition").FirstOrDefault();

            ISessionRepository target = new SessionRepository();

            int organizerId = target.GetOrganizerId(session.SessionId);

            Assert.AreEqual(organizerId, session.EventDefinition.OrganizerId);
        }