### Build and Run on Mac/Linux
Source: https://docs.simplcommerce.com/developer-guide/getting-started.html
Commands to initialize the build script and start the application server.
```bash
sudo ./simpl-build.sh
```
```bash
dotnet run
```
--------------------------------
### Run SimplCommerce via Docker
Source: https://docs.simplcommerce.com/developer-guide/getting-started.html
Use this command to quickly spin up a testing instance of SimplCommerce.
```bash
docker run -p 5000:80 simplcommerce/ci-build
```
--------------------------------
### Configure module project file
Source: https://docs.simplcommerce.com/developer-guide/how-to-add-new-modules.html
Replace the contents of the generated .csproj file with this structure to include necessary project references.
```xml
```
--------------------------------
### Define theme configuration
Source: https://docs.simplcommerce.com/developer-guide/theme-development.html
Create a theme.json file in the theme folder to specify metadata such as the theme name, display name, and version.
```json
{
"name": "YourThemeName",
"fullName": "YourThemeName",
"displayName": "Your theme name",
"version": "1.0.0"
}
```
--------------------------------
### Define module metadata
Source: https://docs.simplcommerce.com/developer-guide/how-to-add-new-modules.html
Create a module.json file to specify the module identity and bundling configuration.
```json
{
"id": "xxx.Module.yyy",
"Name": "Your module name",
"isBundledWithHost": true,
"version": "1.0.0"
}
```
--------------------------------
### Update Database via Package Manager Console
Source: https://docs.simplcommerce.com/developer-guide/getting-started.html
Execute this command in the Visual Studio Package Manager Console to initialize the database schema.
```powershell
Update-Database
```
--------------------------------
### Configure Entity Framework in Program.cs
Source: https://docs.simplcommerce.com/developer-guide/working-with-databases.html
Register the database provider configuration within the application builder.
```csharp
configBuilder.AddEntityFrameworkConfig(options =>
options.UseSqlServer(configuration.GetConnectionString("DefaultConnection"))
);
```
--------------------------------
### Set User Secrets via Command Line
Source: https://docs.simplcommerce.com/developer-guide/development-tips.html
Use the dotnet CLI to programmatically set sensitive configuration values.
```bash
dotnet user-secrets set "ConnectionStrings:DefaultConnection" "Your ConnectionString"
```
--------------------------------
### Configure AWS S3 Settings in appsettings.json
Source: https://docs.simplcommerce.com/developer-guide/amazon-s3.html
Add these credentials and bucket details to your application configuration file.
```json
"AWS": {
"S3": {
"RegionEndpointName": "",
"AccessKeyId": "",
"SecretAccessKey": "",
"BucketName": "",
"PublicEndpoint"
}
}
```
--------------------------------
### Implement custom model mapping
Source: https://docs.simplcommerce.com/developer-guide/intro.html
Create a class implementing ICustomModelBuilder to define specific entity relationships or configurations that deviate from default conventions.
```csharp
public class CatalogCustomModelBuilder : ICustomModelBuilder
{
public void Build(ModelBuilder modelBuilder)
{
modelBuilder.Entity()
.HasOne(x => x.Product)
.WithMany(p => p.ProductLinks)
.HasForeignKey(x => x.ProductId)
.OnDelete(DeleteBehavior.Restrict);
}
}
```
--------------------------------
### Configure SendGrid settings
Source: https://docs.simplcommerce.com/developer-guide/how-to-setup-email-using-sendgrid.html
Add the required SendGrid API credentials and sender information to appsettings.json.
```json
"SendGrid": {
"ApiKey": "Your Send Grid API Key",
"FromEmail": "no-reply@simplcommerce.com",
"FromName": "SimplCommerce"
}
```
--------------------------------
### Create an order in the payment controller
Source: https://docs.simplcommerce.com/developer-guide/how-to-add-new-payment-providers.html
Use this method within your controller to finalize the order after receiving a successful callback from the payment gateway.
```csharp
await _orderService.CreateOrder(currentUser, "PaymentMethodName");
```
--------------------------------
### Register AfterOrderCreatedSendEmailHanlder
Source: https://docs.simplcommerce.com/developer-guide/how-to-setup-email-using-sendgrid.html
Uncomment the registration line in ModuleInitializer.cs to enable the order email handler.
```csharp
//services.AddTransient, AfterOrderCreatedSendEmailHanlder>();
```
--------------------------------
### Configure User Secrets in secrets.json
Source: https://docs.simplcommerce.com/developer-guide/development-tips.html
Define sensitive configuration keys and values within the local secrets.json file.
```json
{
"ConnectionStrings:DefaultConnection": "Your ConnectionString"
}
```
--------------------------------
### Register EmailSenderSmtp Module
Source: https://docs.simplcommerce.com/developer-guide/how-to-setup-email-using-smtp.html
Add the EmailSenderSmtp module to the modules.json file in the WebHost project.
```json
{
"id": "SimplCommerce.Module.EmailSenderSmtp",
"isBundledWithHost": true,
"version": "1.0.0"
}
```
--------------------------------
### Add EmailSenderSendgrid to modules.json
Source: https://docs.simplcommerce.com/developer-guide/how-to-setup-email-using-sendgrid.html
Register the SendGrid module in the WebHost modules.json file.
```json
{
"id": "SimplCommerce.Module.EmailSenderSendgrid",
"isBundledWithHost": true,
"version": "1.0.0"
}
```
--------------------------------
### Register Angular module
Source: https://docs.simplcommerce.com/developer-guide/how-to-add-new-modules.html
Add this line to the ConfigureServices method in ModuleInitializer.cs to register the Angular module.
```csharp
GlobalConfiguration.RegisterAngularModule("yourAngularModuleName");
```
--------------------------------
### Register DbContext in ServiceCollectionExtensions.cs
Source: https://docs.simplcommerce.com/developer-guide/working-with-databases.html
Configure the DbContext pool with the specific database provider and migration assembly.
```csharp
services.AddDbContextPool(options =>
options.UseSqlServer(configuration.GetConnectionString("DefaultConnection"),
b => b.MigrationsAssembly("SimplCommerce.WebHost")));
return services;
```
--------------------------------
### Update Project References for S3 Storage
Source: https://docs.simplcommerce.com/developer-guide/amazon-s3.html
Modify the project file to replace the local storage module with the Amazon S3 module.
```xml
```
```xml
```
--------------------------------
### Register domain entities in DbContext
Source: https://docs.simplcommerce.com/developer-guide/intro.html
Use this method to register all non-abstract classes inheriting from Entity within the OnModelCreating process.
```csharp
private static void RegisterEntities(ModelBuilder modelBuilder, IEnumerable typeToRegisters)
{
var entityTypes = typeToRegisters.Where(x => x.GetTypeInfo().IsSubclassOf(typeof(Entity)) && !x.GetTypeInfo().IsAbstract);
foreach (var type in entityTypes)
{
modelBuilder.Entity(type);
}
}
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.