Exemplo n.º 1
0
 private Privs(Datamodel.UserPrivs p)
 {
     canPromote   = p.canPromote;
     canCertify   = p.canCertify;
     canAssign    = p.canAssign;
     canStartOps  = p.canStartOps;
     isFleetAdmin = p.isFleetAdmin;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Gets the privilege set for a user
 /// </summary>
 /// <param name="userId"></param>
 /// <returns></returns>
 public static Privs FetchByUser(int userId)
 {
     Datamodel.UserPrivs p = null;
     if (Datamodel.UserPrivs.FetchByUser(ref p, userId))
     {
         return(new Privs(p));
     }
     else
     {
         return(null);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// </summary>
        /// <param name="output"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public static bool FetchByUser(ref UserPrivs output, int user)
        {
            SQLiteDataReader reader = DBI.DoPreparedQuery(
                "SELECT * FROM UserPrivs WHERE user=@user;",
                new Tuple <string, object>("@user", user));

            if (reader != null && reader.Read())
            {
                output = UserPrivs.Factory(reader);
                return(true);
            }
            return(false);
        }
Exemplo n.º 4
0
        public static UserPrivs Factory(int user, bool canPromote,
                                        bool canCertify, bool canAssign, bool canStartOps,
                                        bool isFleetAdmin)
        {
            UserPrivs result = new UserPrivs(
                user: user,
                canPromote: canPromote,
                canCertify: canCertify,
                canAssign: canAssign,
                canStartOps: canStartOps,
                isFleetAdmin: isFleetAdmin
                );

            return(result);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Creates a new set of privileges for a user
        /// </summary>
        /// <param name="output"></param>
        /// <param name="user"></param>
        /// <param name="canPromote"></param>
        /// <param name="canCertify"></param>
        /// <param name="canAssign"></param>
        /// <param name="canStartOps"></param>
        /// <param name="isFleetAdmin"></param>
        /// <returns></returns>
        public static bool Create(ref UserPrivs output, int user,
                                  bool canPromote, bool canCertify, bool canAssign, bool canStartOps,
                                  bool isFleetAdmin)
        {
            int result = DBI.DoPreparedAction(
                @"INSERT INTO UserPrivs (user, canPromote, canCertify, 
				canAssign, canStartOps, isFleetAdmin) 
				VALUES (@user, @promote, @cert, @assign, @ops, @fleetad);"                ,
                new Tuple <string, object>("@user", user),
                new Tuple <string, object>("@promote", canPromote),
                new Tuple <string, object>("@cert", canCertify),
                new Tuple <string, object>("@assign", canAssign),
                new Tuple <string, object>("@ops", canStartOps),
                new Tuple <string, object>("@fleetad", isFleetAdmin));

            if (result == 1)
            {
                return(UserPrivs.FetchByUser(ref output, user));
            }
            return(false);
        }