private void AddSession() { if (MessageBox.Show("Are you sure", "", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { var sessions = SessionService.GetAllSessions().Where(d => d.CourseId == SelectedCourse.Id); if (ScheduleConflict(sessions)) { //if Session Start is within Start and End of existing session for the same course - there is a schedule conflict and the operation must not be allowed MessageBox.Show("Schedule Conflict"); return; } //create location from strings var address = AddressService.AddAddress(new Address() { ZipCode = VenueAddress, }); var location = LocationService.AddLocation(new Location() { Address = address, Capacity = VenueCapacity }); Session = SessionService.AddSession(Session); var sessionLocation = SessionLocationService.Add(new Session_Location() { Session = Session, Location = location }); BackProc(); } }
public ActionResult Login(LoginRequest request) { // Steps for Implementation // 1. Check if user exists // 1. Create JWT Token // 2. Create Session // 3. Add Session to DB // 4. Return JWT Token on success var user = _userAccountService.ReadUserFromDBUsingEmail(request.EmailAddress.ToLower()); if (user == null) { return(new BadRequestObjectResult("User not found.")); } if (!_passwordService.ValidatePassword(request.Password, user.PasswordSalt, user.PasswordHash)) { // Limit attempts // Invalidate all sessions return(new BadRequestObjectResult("Incorrect password.")); } string jwtToken = JWTService.CreateToken(); Session session = new Session(user.Email, jwtToken); if (!_sessionService.AddSession(session)) { return(new StatusCodeResult(StatusCodes.Status500InternalServerError)); } var jsonString = JsonSerializer.Serialize(session); var jObject = JObject.Parse(jsonString); jObject.Add("firstName", user.FirstName); return(new OkObjectResult(jObject.ToString())); }
public void AddSession() { var token = CryptoService.GenerateToken(); var session = new Session("*****@*****.**", token); var added = ss.AddSession(session); Assert.IsTrue(added); }
private void btnSave_Click(object sender, EventArgs e) { int result = CRUDStatusCode.ERROR; try { _sessionService = new SessionService(); if (model == null) { //Add model = new DataService.Model.Session() { Code = txtCode.Text, Name = txtName.Text }; result = _sessionService.AddSession(model); if (result == CRUDStatusCode.SUCCESS) { Utilities.ShowMessage(CommonMessage.ADD_SUCESSFULLY); Logging.LogBusiness(string.Format("{0} {1} {2}", Common.Session.GetUserName(), Common.Constants.LogAction.Create, "buổi phát " + model.Code + " " + model.Name), Common.Constants.BusinessLogType.Create); } } else { //Edit model.Code = txtCode.Text; model.Name = txtName.Text; result = _sessionService.EditSession(model); if (result == CRUDStatusCode.SUCCESS) { Utilities.ShowMessage(CommonMessage.EDIT_SUCESSFULLY); Logging.LogBusiness(string.Format("{0} {1} {2}", Common.Session.GetUserName(), Common.Constants.LogAction.Update, "buổi phát " + model.Code + " " + model.Name), Common.Constants.BusinessLogType.Update); } } } catch (Exception ex) { throw; } finally { _sessionService = null; } }
public void adding_a_session_should_use_the_IConferenceDataProvider_to_save() { var theSession = new Session() { Venue = new Venue(), Start = new DateTime(2016, 8, 4), Talk = new Talk(), TalkType = new TalkType(), Status = SessionStatus.Open }; var theDataProvider = new Mock <IConferenceDataProvider>(); var sessionService = new SessionService(theDataProvider.Object); theDataProvider.Setup(x => x.Sessions).Returns(new[] { new Session() }.AsQueryable()); sessionService.AddSession(theSession); theDataProvider.Verify(x => x.AddSession(theSession), Times.AtLeastOnce()); }
private void AddSessionAndLocation() { var randomCourse = CourseService.GetAllCourses()[random.Next(100)]; var randomAddress = AddressService.GetAllAdresses()[random.Next(100)]; var newLocation = LocationService.AddLocation(new Location() { Address = randomAddress, }); var addedSession = new Session() { Course = randomCourse }; SessionService.AddSession(addedSession); SessionLocationService.Add(new Session_Location() { Session = addedSession, Location = newLocation }); }