コード例 #1
0
        public bool UpdateCooldown(User user, Moneyfaucet moneyfaucet, DateTime cooldown)
        {
            string query = $"User_UpdateCooldown";

            try
            {
                if (OpenConnection())
                {
                    using (SqlCommand command = new SqlCommand(query, sql_connection))
                    {
                        command.CommandType = System.Data.CommandType.StoredProcedure;
                        try
                        {
                            command.Parameters.AddWithValue("@UserID", user.ID);
                            command.Parameters.AddWithValue("@MoneyfaucetID", moneyfaucet.ID);

                            //To convert the c# datetime into sql format, use these 2 lines
                            SqlParameter parameter = command.Parameters.AddWithValue("@Cooldown", System.Data.SqlDbType.DateTime);
                            parameter.Value = cooldown;

                            command.ExecuteNonQuery();

                            return(true);
                        }
                        catch (SqlException ex)
                        {
                            throw ex;
                        }
                    }
                }
            }
            catch (SqlException)
            {
                return(false);
            }
            finally
            {
                CloseConnection();
            }
            return(false);
        }
コード例 #2
0
 public bool UpdateCooldown(User user, Moneyfaucet moneyfaucet, DateTime cooldown)
 {
     return(context.UpdateCooldown(user, moneyfaucet, cooldown));
 }