public KeyValuePair<Guid, DateTime> StartSession(long userId, Guid ticket)
        {
            var session = _data.Sessions.SingleOrDefault(s => s.userId == userId);
            if (session != null)
                _data.Sessions.DeleteObject(session);

            var newSession = new Sessions() { userId = userId, ticket = ticket, validTill = DateTime.Now.AddMinutes(10) };

            _data.Sessions.AddObject(newSession);

            _data.SaveChanges();

            return new KeyValuePair<Guid, DateTime>(ticket, newSession.validTill);
        }
Example #2
0
 /// <summary>
 /// Create a new Sessions object.
 /// </summary>
 /// <param name="userId">Initial value of the userId property.</param>
 /// <param name="ticket">Initial value of the ticket property.</param>
 /// <param name="validTill">Initial value of the validTill property.</param>
 public static Sessions CreateSessions(global::System.Int64 userId, global::System.Guid ticket, global::System.DateTime validTill)
 {
     Sessions sessions = new Sessions();
     sessions.userId = userId;
     sessions.ticket = ticket;
     sessions.validTill = validTill;
     return sessions;
 }
Example #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Sessions EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToSessions(Sessions sessions)
 {
     base.AddObject("Sessions", sessions);
 }