コード例 #1
0
        public static IList <LeaderboardEntry> RetrieveLocalLeaderboard(int userId, int locality = 2)
        {
            var parameters = new List <SqlParameter>
            {
                new SqlParameter("userId", userId),
                new SqlParameter("locality", locality)
            };

            var dataTable = DatabaseCommon.PerformAction("GetLocalLeaderboardInfo", parameters);

            return(DatabaseCommon.ConvertTable(dataTable, LeaderboardEntry.FromDataRow));
        }
コード例 #2
0
        public static User UpdatePassword(int userId, string userPassword)
        {
            var parameters = new List <SqlParameter>
            {
                new SqlParameter("userId", userId),
                new SqlParameter("password", userPassword)
            };

            var dt = DatabaseCommon.PerformAction("UpdateUserPassword", parameters);

            return(DatabaseCommon.ConvertRow(dt, PopulateUser));
        }
コード例 #3
0
        public static IList <LeaderboardEntry> RetrieveTopLeaderboard(int rowCount, int?currentUserId = null)
        {
            var parameters = new List <SqlParameter>
            {
                new SqlParameter("rowCount", rowCount),
                new SqlParameter("userId", currentUserId)
            };

            var dataTable = DatabaseCommon.PerformAction("GetTopLeaderboardInfo", parameters);

            return(DatabaseCommon.ConvertTable(dataTable, LeaderboardEntry.FromDataRow));
        }
コード例 #4
0
        public static Hire SetEndMileage(int hireId, int endMileage)
        {
            var parameters = new List <SqlParameter>
            {
                new SqlParameter("hireId", hireId),
                new SqlParameter("mileage", endMileage)
            };

            var dt = DatabaseCommon.PerformAction("UpdateHireFinalMileage", parameters);

            return(DatabaseCommon.ConvertRow(dt, Hire.FromDataRow));
        }
コード例 #5
0
        public static Hire RetrieveSingleHire(string bookingReference, string emailAddress)
        {
            var parameters = new List <SqlParameter>
            {
                new SqlParameter("bookingReference", bookingReference),
                new SqlParameter("emailAddress", emailAddress)
            };

            var dataTable = DatabaseCommon.PerformAction("GetHireForBookingReferenceAndEmailAddress", parameters);

            return(DatabaseCommon.ConvertRow(dataTable, Hire.FromDataRow));
        }
コード例 #6
0
        public static User CreateUser(string emailAddress, string firstName, string surname)
        {
            var parameters = new List <SqlParameter>
            {
                new SqlParameter("emailAddress", emailAddress),
                new SqlParameter("firstName", firstName),
                new SqlParameter("surname", surname)
            };

            var dt = DatabaseCommon.PerformAction("CreateNewUser", parameters);

            return(DatabaseCommon.ConvertRow(dt, PopulateUser));
        }
コード例 #7
0
        public static Hire CreateHire(int userId, string bookingReference, DateTime hireEndDate, int startMileage)
        {
            var parameters = new List <SqlParameter>
            {
                new SqlParameter("userId", userId),
                new SqlParameter("bookingReference", bookingReference),
                new SqlParameter("hireEndDate", hireEndDate == DateTime.MinValue ? DBNull.Value : (object)hireEndDate),
                new SqlParameter("startMileage", startMileage)
            };

            var dt = DatabaseCommon.PerformAction("CreateNewHire", parameters);

            return(DatabaseCommon.ConvertRow(dt, Hire.FromDataRow));
        }
コード例 #8
0
        public static User RetrieveUser(string email)
        {
            var parameters = new List <SqlParameter>
            {
                new SqlParameter
                {
                    ParameterName = "email",
                    Value         = email
                }
            };

            var dataTable = DatabaseCommon.PerformAction("GetUserForEmail", parameters);

            return(DatabaseCommon.ConvertRow(dataTable, PopulateUser));
        }
コード例 #9
0
        public static User RetrieveUser(Guid sessionId)
        {
            var parameters = new List <SqlParameter>
            {
                new SqlParameter
                {
                    ParameterName = "SessionId",
                    Value         = sessionId
                }
            };

            var dataTable = DatabaseCommon.PerformAction("GetUserForSessionId", parameters);

            return(DatabaseCommon.ConvertRow(dataTable, PopulateUser));
        }
コード例 #10
0
        public static Session CreateSession(int userId)
        {
            var parameters = new List <SqlParameter>
            {
                new SqlParameter
                {
                    ParameterName = "UserId",
                    Value         = userId
                }
            };

            var dataTable = DatabaseCommon.PerformAction("AddSession", parameters);

            return(DatabaseCommon.ConvertRow(dataTable, PopulateSession));
        }
コード例 #11
0
        public static TagType RetrieveTagType(int tagTypeId)
        {
            var parameters = new List <SqlParameter>
            {
                new SqlParameter
                {
                    ParameterName = "TagTypeId",
                    Value         = tagTypeId
                }
            };

            var dataTable = DatabaseCommon.PerformAction("GetTagTypeForTageTypeId", parameters);

            return(dataTable != null && dataTable.Rows.Count > 0 ? PopulateTagType(dataTable.Rows[0]) : null);
        }
コード例 #12
0
        public static List <Achievement> RetrieveOutstandingUserAchievements(int userId)
        {
            var parameters = new List <SqlParameter>
            {
                new SqlParameter
                {
                    ParameterName = "userId",
                    Value         = userId
                }
            };

            var dataTable = DatabaseCommon.PerformAction("GetOutstandingAchievementsForUserId", parameters);

            return(dataTable != null && dataTable.Rows.Count > 0 ? PopulateAchievements(dataTable) : null);
        }
コード例 #13
0
        public static void CreateUserAchievement(int achievementId, int userId)
        {
            var parameters = new List <SqlParameter>
            {
                new SqlParameter
                {
                    ParameterName = "achievementId",
                    Value         = achievementId
                },
                new SqlParameter
                {
                    ParameterName = "userId",
                    Value         = userId
                }
            };

            DatabaseCommon.PerformAction("AddUserAchievement", parameters);
        }
コード例 #14
0
        public static List <Transaction> RetrieveXTransactionsForUser(int count, int userId)
        {
            var parameters = new List <SqlParameter>
            {
                new SqlParameter
                {
                    ParameterName = "count",
                    Value         = count
                },
                new SqlParameter
                {
                    ParameterName = "userId",
                    Value         = userId
                }
            };

            var dataTable = DatabaseCommon.PerformAction("GetXTransactionsForUser", parameters);

            return(dataTable != null && dataTable.Rows.Count > 0 ? PopulateTransactionList(dataTable) : new List <Transaction>());
        }
コード例 #15
0
        public static Transaction CreateTransactionForUserAndTag(int userId, int points, int tagId, TransactionType transactionTypeId)
        {
            var transaction = CreateTransaction(userId, points, transactionTypeId);

            var parameters = new List <SqlParameter>
            {
                new SqlParameter
                {
                    ParameterName = "tagId",
                    Value         = tagId
                },
                new SqlParameter
                {
                    ParameterName = "transactionId",
                    Value         = transaction.TransactionId
                }
            };

            var dataTable = DatabaseCommon.PerformAction("AddTransactionTag", parameters);

            return(dataTable != null && dataTable.Rows.Count > 0 ? PopulateTransaction(dataTable.Rows[0]) : null);
        }
コード例 #16
0
        public static int GetUsersUsablePoints(int userId)
        {
            var parameters = new List <SqlParameter>
            {
                new SqlParameter
                {
                    ParameterName = "userId",
                    Value         = userId
                }
            };

            var dataTable = DatabaseCommon.PerformAction("GetUsersUsablePoints", parameters);

            var usablePoints = 0;

            if (dataTable != null && dataTable.Rows.Count > 0)
            {
                usablePoints = dataTable.Rows[0].Field <int>("Points");
            }

            return(usablePoints);
        }
コード例 #17
0
        public static IList <Hire> RetrieveAllHires()
        {
            var dataTable = DatabaseCommon.PerformAction("GetAllHires", null);

            return(DatabaseCommon.ConvertTable(dataTable, Hire.FromDataRow));
        }