Beispiel #1
0
        public UserInfo UpdateUser(User u, APISession session, DynamicDictionary parameters)
        {
            UserInfo s = this.Bind<UserInfo>(new string[]{"EntityKey", "EntityState"});

            if (s.UserId != u.UserId && !u.IsAdmin())
            {
                throw new AccessException(i18n.API_ErrorSessionPrivilegesRequired);
            }

            return UserInfo.Save(s);
        }
Beispiel #2
0
        public List<UserInfo> GetUsersInformation(User u, APISession session, DynamicDictionary parms)
        {
            List<User> users = User.GetAll();
            List<UserInfo> uis = new List<UserInfo>();

            users.ForEach(ux => {
                uis.Add(User.GetBasicUserInformation(ux));
            });

            return uis;
        }
Beispiel #3
0
        public Checkin CheckInPUT(User u, APISession session, DynamicDictionary parms)
        {
            Checkin t = this.Bind();
            t.RegisteredBy = u.UserId;

            // Check roles to see if the user can post
            if (!u.IsAdmin() || t.UserId == 0)
            {
                t.UserId = u.UserId;
            }

            return Checkin.CheckIn(t);
        }
Beispiel #4
0
 public Checkin CheckOut(User u, APISession session, DynamicDictionary parms)
 {
     if (u.IsAdmin())
     {
         return Checkin.CheckOut(parms["id"]);
     }
     else
     {
         Checkin cin = Checkin.GetLastForUser(u.UserId);
         if (cin.EndTime.HasValue)
         {
             return cin;
         }
         return Checkin.CheckOut(cin.CheckInId);
     }
 }
Beispiel #5
0
 partial void InsertSession(Session instance);
Beispiel #6
0
        /// <summary>
        /// Sets a new session object
        /// </summary>
        /// <param name="s"></param>
        public static Session Set(int userId, TimeSpan timeOut, bool rememberMe)
        {
            using (EntityContext ctx = new EntityContext())
            {
                Session s = new Session()
                {
                    UserId = userId,
                    CreatedAt = DateTime.Now,
                    ExpiresAt = rememberMe ? DateTime.MaxValue : DateTime.Now.ToCommonTime().Add(timeOut),
                    LastAccess = DateTime.Now.ToUniversalTime(),
                    Data = string.Empty
                };

                s.ValidateAndRaise();

                s.SessionId = Guid.NewGuid();
                ctx.Sessions.AddObject(s);
                ctx.SaveChanges();
                return s;
            }
        }
Beispiel #7
0
        /// <summary>
        /// Sets a new session object
        /// </summary>
        /// <param name="s"></param>
        public static Session Set(Session s)
        {
            using (EntityContext ctx = new EntityContext())
            {
                s.ValidateAndRaise();

                s.SessionId = Guid.NewGuid();
                ctx.Sessions.AddObject(s);
                ctx.SaveChanges();

                return s;
            }
        }
Beispiel #8
0
 public Checkin GetCurrentForUser(User u, APISession session, DynamicDictionary parms)
 {
     return Checkin.GetLastForUser(parms["id"]);
 }
Beispiel #9
0
 public List<Checkin> GetCurrent(User u, APISession session, DynamicDictionary parameters)
 {
     return Checkin.GetCurrent();
 }
Beispiel #10
0
 public Checkin CheckOutCurrent(User u, APISession session, DynamicDictionary parms)
 {
     return Checkin.CheckOutByUserId(u.UserId);
 }
Beispiel #11
0
 public User DeleteUser(User u, APISession session, DynamicDictionary parameters)
 {
     return null;
 }
Beispiel #12
0
 public List<CheckinNotification> GetLast(User u, APISession session, DynamicDictionary parameters)
 {
     return Checkin.GetNotificationStream(parameters["amount"]);
 }
 /// <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(Session session)
 {
     base.AddObject("Sessions", session);
 }
 /// <summary>
 /// Create a new Session object.
 /// </summary>
 /// <param name="sessionId">Initial value of the SessionId property.</param>
 public static Session CreateSession(global::System.Guid sessionId)
 {
     Session session = new Session();
     session.SessionId = sessionId;
     return session;
 }
Beispiel #15
0
 public UserInfo GetUser(User u, APISession session, DynamicDictionary parameters)
 {
     return UserInfo.GetByUserId(parameters["id"]);
 }
Beispiel #16
0
 partial void UpdateSession(Session instance);
Beispiel #17
0
 partial void DeleteSession(Session instance);
Beispiel #18
0
        public UserInfo AddUser(User u, APISession session, DynamicDictionary parameters)
        {
            UserInfo s = parameters.Fill<UserInfo>();

            return UserInfo.Save(s);
        }