Changing order status value automatically Based on ordering Date

Viewed 27

I am building an E-Commerce Application with Asp.net core MVC.

Order Model is build and when a user add an order it is created and saved in the DB.

But I want to add the following functionality that when a user places an order, the status is set to pending, and then after 2 days from placing the order, it changes to shipped, and after 4 days from placing the order it changes to be Delivered and then removed from the DB.

how can I implement this kind of action ?

1 Answers

`You can use the "quartz job scheduler library".

// Add Quartz services
builder.Services.AddHostedService();
builder.Services.AddSingleton<IJobFactory, SingletonJobFactory>();
builder.Services.AddSingleton<ISchedulerFactory, StdSchedulerFactory>();

// Add our job
builder.Services.AddSingleton();
builder.Services.AddSingleton(new JobSchedule( jobType: typeof(RemindersJob), cronExpression: "0 0/5 * * * ?")); // run every 5 min
builder.Services.AddSingleton(); builder.Services.AddSingleton(new JobSchedule( jobType: typeof(EmailJob), cronExpression: "0 0/1 * * * ?"));

https://www.quartz-scheduler.net/documentation/quartz-3.x/packages/aspnet-core-integration.html`

Related