/// <summary> /// Determines whether the specified session is registered. /// </summary> /// <param name="s">The session to be validated.</param> /// <returns> /// <c>true</c> if the specified session is registered; otherwise, <c>false</c>. /// </returns> public virtual bool IsJoined(Session s) { Logger.Instance.Info(string.Format("Called IsJoined with session key <{0}> for user <{1}>", s.Key, s.User.Name)); var sessions = from rs in this.registeredSessions where rs.Key.Equals(s.Key) select rs; if (sessions.Any()) { return true; } return false; }
private static void AddSessions() { var newSession = new Session { StartTime = DateTime.Now, Title = "ObjC for CS devs" }; var newSession2 = new Workshop { StartTime = DateTime.Now.AddMinutes(2), Title = "Entity Framework 2" }; var newSession3 = new Session { StartTime = DateTime.Now.AddMinutes(2), Title = "MongoDB" }; _sessionRepo.Save(newSession); _sessionRepo.Save(newSession2); _sessionRepo.Save(newSession3); Console.WriteLine("Saved new sessions!"); }
public MaximumNumberOfAttendeesReachedException(Session session) : base("The maximum number of attendees has been reached for the session " + session.Title) { }
public string SignIn(Credential credential) { try { string user = credential.user; string pass = credential.pass; if (PdpUserProvider.IsValidUser(user, pass)) { Interlocked.Increment(ref actives_users); Interlocked.Increment(ref accesscounter); Session session = new Session(); session.user = user; using (var connect = new Connect()) { connect.BeginTrx(); SqlConnection sqlconn = connect.GetConnection(); var smapper = new SessionDataMapper(sqlconn); smapper.SetTransaction(connect.Transaction); //smapper.Insert(session); } return authProvider.AutenticateUser(credential); } return null; } catch (Exception exception) { throw new FaultException<ServerError>(new ServerError()); } }
/// <summary> /// Create a new Session object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="title">Initial value of the Title property.</param> /// <param name="startHour">Initial value of the StartHour property.</param> /// <param name="durationInMinutes">Initial value of the DurationInMinutes property.</param> /// <param name="day">Initial value of the Day property.</param> /// <param name="description">Initial value of the Description property.</param> /// <param name="track">Initial value of the Track property.</param> /// <param name="startMinute">Initial value of the StartMinute property.</param> /// <param name="capacity">Initial value of the Capacity property.</param> /// <param name="agenda_Id">Initial value of the Agenda_Id property.</param> public static Session CreateSession(global::System.Int32 id, global::System.String title, global::System.Int32 startHour, global::System.Int32 durationInMinutes, global::System.Int32 day, global::System.String description, global::System.Int32 track, global::System.Int32 startMinute, global::System.Int32 capacity, global::System.Int32 agenda_Id) { Session session = new Session(); session.Id = id; session.Title = title; session.StartHour = startHour; session.DurationInMinutes = durationInMinutes; session.Day = day; session.Description = description; session.Track = track; session.StartMinute = startMinute; session.Capacity = capacity; session.Agenda_Id = agenda_Id; return session; }
/// <summary> /// Deprecated Method for adding a new object to the Sessions EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToSessions(Session session) { base.AddObject("Sessions", session); }
public void AddSessionOrWorkshop() { Session newSession; if (_isWorkshop) { newSession = new Workshop { Title = _sessionName }; } else { newSession = new Session() { Title = _sessionName }; } _sessionRepository.Save(newSession); SessionsAvailable.Add(newSession); MessageBox.Show("Session saved!"); }
/// <summary> /// Registers the specified user. /// </summary> /// <param name="user">The user to be registered.</param> /// <returns> /// The registered session for the supplied user. /// </returns> public virtual Session Join(User user) { Logger.Instance.Info(string.Format("User <{0}> joined", user.Name)); var sessions = from rs in this.registeredSessions where rs.User == user select rs; if (sessions.Any()) { throw new InvalidOperationException(string.Format("User '{0}' is already registered.", user.Name)); } var s = new Session { User = user, ExpiryDate = DateTime.Now.AddHours(1) }; this.registeredSessions.Add(s); this.subscribers.ForEach(callback => callback.NotifyUserJoined(user)); return s; }
/// <summary> /// Sends the specified message. /// </summary> /// <param name="message">The message.</param> /// <param name="sender">The sender.</param> public virtual void Send(Message message, Session sender) { Logger.Instance.Info(string.Format("User <{0}> sent message <{1}>", sender.User.Name, message.Payload)); message.Sender = sender.User; this.subscribers.ForEach(callback => callback.NotifyNewMessage(message)); }
/// <summary> /// Leaves the specified session. /// </summary> /// <param name="session">The session.</param> public virtual void Leave(Session session) { Logger.Instance.Info(string.Format("User <{0}> left", session.User.Name)); var sessions = from rs in this.registeredSessions where rs.Key.Equals(session.Key) select rs; if (!sessions.Any()) { throw new InvalidOperationException("Session is not registered."); } this.registeredSessions.Remove(sessions.SingleOrDefault()); this.subscribers.ForEach(callback => callback.NotifyUserLeft(session.User)); }