This repository demonstrates the implementation of a SaaS application using the SaaSus SDK with .NET Framework 4.8 and .NET 8.
See the documentation API implementation using SaaS Platform
-
Clone the sample API project repository
git clone git@github.com:saasus-platform/implementation-sample-api-csharp.git
-
Clone the SaaSus SDK repository
Clone the SaaSus SDK into the same directory level as the sample API project:git clone git@github.com:saasus-platform/saasus-sdk-csharp.git
-
Navigate to the SaaSus SDK directory
cd saasus-sdk-csharp
-
Build the SDK
Build the SDK project in Release configuration:dotnet build -c Release
-
Generate the NuGet package
Create a NuGet package using the following command:dotnet pack -c Release
The NuGet package file (e.g.,
saasus-sdk-csharp.1.0.0.nupkg) will be located in thebin/Releasefolder. -
Set up a local NuGet feed
- Create a directory for the local NuGet feed:
mkdir C:\LocalNuGetFeed - Copy the generated
.nupkgfile into the local NuGet feed directory:cp bin/Release/saasus-sdk-csharp.1.0.0.nupkg C:\LocalNuGetFeed
- Create a directory for the local NuGet feed:
-
Configure the local feed in Visual Studio
- Open Visual Studio.
- Navigate to Tools → Options → NuGet Package Manager → Package Sources.
- Click Add, and set the following:
- Name:
LocalFeed(or any preferred name) - Source:
C:\LocalNuGetFeed
- Name:
- Save the changes by clicking OK.
-
Open the .NET Framework 4.8 project in Visual Studio
Open SampleWebAppDotNet48.sln located in implementation-sample-api-csharp/SampleWebAppDotNet48/ using Visual Studio. -
Install the SaaSus SDK
Use the local NuGet feed to install the SaaSus SDK package:- In Visual Studio, open the sample API project.
- Navigate to Tools → NuGet Package Manager → Manage NuGet Packages for Solution.
- Select
LocalFeedas the package source. - Search for
saasus-sdk-csharpand install the package.
-
Open Visual Studio as an Administrator
Ensure you open Visual Studio with administrative privileges to configure the application URL. -
Set the application URL
- Right-click the project in Solution Explorer and select Properties.
- Go to the Web tab.
- Set the Project URL to
http://localhost:80/.
Edit the Web.config file in the SampleWebAppDotNet48 directory to set the SaaSus API credentials. Add or modify the following entries:
<configuration>
<appSettings>
<add key="SAASUS_SECRET_KEY" value="xxxxxxxxxx" />
<add key="SAASUS_API_KEY" value="xxxxxxxxxx" />
<add key="SAASUS_SAAS_ID" value="xxxxxxxxxx" />
</appSettings>
</configuration>Replace xxxxxxxxxx with the values from the SaaSus Admin Console.
Run the following command to start the database using Docker:
docker-compose up -d- Download PostgreSQL 13 from the official website:
PostgreSQL Windows Download - Run the installer and follow the setup instructions:
- Superuser Username:
postgres(default, cannot be changed) - Superuser Password:
postgres(recommended for local setup) - Port:
5432(default, leave unchanged)
- Superuser Username:
- Open SQL Shell (psql):
- Press
Windows + Sand search for SQL Shell (psql). - Click to open it.
- Press Enter for all prompts until it asks for the password.
- Enter the Superuser Password set during installation.
- You should now see:
postgres=#
- Press
- Run
psqland applyinit.sqlusing the full path:- For .NET Framework 4.8:
\i 'C:/path/to/implementation-sample-api-csharp/SampleWebAppDotNet48/init.sql' - For .NET 8:
\i 'C:/path/to/implementation-sample-api-csharp/SampleWebAppDotNet8/init.sql'
- For .NET Framework 4.8:
- Open the project in Visual Studio.
- Build the project in Release or Debug mode.
- Run the application.
-
Clone the sample API project repository
git clone git@github.com:saasus-platform/implementation-sample-api-csharp.git
-
Clone the SaaSus SDK repository
Clone the SaaSus SDK into the same directory level as the sample API project:git clone git@github.com:saasus-platform/saasus-sdk-csharp.git
-
Navigate to the .NET 8 project directory
cd implementation-sample-api-csharp/SampleWebAppDotNet8
Run the following command to add the SaaSus SDK as a project reference:
dotnet add SampleWebAppDotNet8.csproj reference ../../saasus-sdk-csharp/saasus-sdk-csharp.csproj
dotnet sln add ../../saasus-sdk-csharp/saasus-sdk-csharp.csprojEdit the appsettings.json file in the SampleWebAppDotNet8 directory to set the SaaSus API credentials. Modify it as follows:
{
"SaasusSettings": {
"SAASUS_SECRET_KEY": "xxxxxxxxxx",
"SAASUS_API_KEY": "xxxxxxxxxx",
"SAASUS_SAAS_ID": "xxxxxxxxxx"
}
}Replace xxxxxxxxxx with the values from the SaaSus Admin Console.
Follow the same Windows installation steps as in the .NET Framework 4.8 section, ensuring you apply the correct init.sql for the respective application.
-
Build the project:
dotnet build
-
Run the project:
dotnet run