public HttpResponseMessage Post(List <SessionViewModel> sessionList) { List <Session> dbSessions = sessionList.Select(x => ModelConverter.ToDbSessionModel(x)).ToList(); if (dbSessions.Count == 1) { Session session = dbSessions.First(); if (session.Id > 0) { sessionRepository.UpdateSession(session); } else { session = sessionRepository.CreateSession(session); } } else { sessionRepository.BulkSessionUpdate(dbSessions); } // OMG FIX THIS LATER sessionList = sessionRepository.GetSessionList(dbSessions.First().CampaignId).Select(x => ModelConverter.ToSessionViewModel(x)).ToList(); return(Request.CreateResponse(HttpStatusCode.OK, dbSessions)); }
public RegisterUserResponse RegisterUser(RegisterUserRequest request) { var user = UserRepository.RetrieveUser(request.EmailAddress, request.BookingReference); if (user == null) { return(new RegisterUserResponse { Success = false, ErrorMessage = "User not Found" }); } user.Password = request.Password; user = UserRepository.UpdateUser(user); var session = SessionRepository.CreateSession(user.UserId); if (session == null) { return(new RegisterUserResponse { Success = false, ErrorMessage = "Session could not be Created" }); } return(new RegisterUserResponse { Success = true, SessionId = session.SessionId }); }
public async Task IntegrationTestCreateSession() { // Arrange SessionRepository repository = new SessionRepository(DevelopmentStorageAccountConnectionString); String dummyUserId = "DummyUserId"; // Act Guid newSessionGuid = await repository.CreateSession(dummyUserId, PlayerColour.Black); // Assert Assert.IsNotNull(newSessionGuid); var dataTable = repository.GetTableForSessionData(newSessionGuid); TableOperation operation = TableOperation.Retrieve <SessionTableEntry>(newSessionGuid.ToString(), dummyUserId); TableResult result = await SessionTable.ExecuteAsync(operation); Assert.IsNotNull(result.Result); Assert.IsInstanceOfType(result.Result, typeof(SessionTableEntry)); SessionTableEntry resultStronglyTyped = result.Result as SessionTableEntry; Assert.AreEqual(dummyUserId, resultStronglyTyped.OwnerId); Assert.AreEqual(Guid.Empty, resultStronglyTyped.PhaseId); Assert.AreEqual(SessionPhase.NotStarted, resultStronglyTyped.PhaseType); Assert.IsTrue(resultStronglyTyped.IsColourUsed(PlayerColour.Black)); operation = TableOperation.Retrieve <NationTableEntry>(newSessionGuid.ToString(), "Nation_" + dummyUserId); result = await dataTable.ExecuteAsync(operation); Assert.IsNotNull(result.Result); Assert.IsInstanceOfType(result.Result, typeof(NationTableEntry)); NationTableEntry resultPlayerStronglyTyped = result.Result as NationTableEntry; Assert.AreEqual(newSessionGuid, resultPlayerStronglyTyped.SessionId); Assert.AreEqual(dummyUserId, resultPlayerStronglyTyped.UserId); Assert.AreEqual(Guid.Empty, resultPlayerStronglyTyped.CompletedPhase); }
public HttpResponseMessage Post(CampaignViewModel campaignVM) { var repro = new CampaignRepository(); Campaign campaignDb = ModelConverter.ToDBCampaign(campaignVM); if (campaignVM.Id > 0) { repro.UpdateCampaign(campaignDb); } else { campaignDb = repro.CreateCampaign(campaignDb); Session firstSession = new Session() { CampaignId = campaignDb.Id }; sessionRepository.CreateSession(firstSession); } //var list = repro.GetCampaignList(); return(Get()); }
public void CreateSession(Session session) { _sessionRepository.CreateSession(session); }
public Session CreateSession(ApplicationDbContext _db, Session s) { return(_SessionRepo.CreateSession(_db, s)); }
public Session CreateSession(Session session) { var sessionResponse = _SessionRepo.CreateSession(session); return(sessionResponse); }