redfoxx
redfoxx
CC#
Created by redfoxx on 11/6/2022 in #help
How to organize and apply delivery fee in an e-commerce
I'm trying to do an e-commerce with *DotNet * and RazorPages. I have the following contexts in my app: Cart, Ordering, Fullfillment, Invoicing. I have decided that I want to apply a delivery fee to a new order , before the order is "Placed" (i.e., paid for). The idea goes like this: When a customer goes from shopping cart to checkout, a new order is created and a timer starts, e.g., 15 mins. During this time, the order lines and delivery fee cannot be altered. While timer >0, the order can be placed. If the timer goes to 0, the checkout "session" times out and the order is deleted. The customer is returned to their cart and must go to checkout again, in which case a new order will be created with the current delivery fee. In my code, DeliveryFee is defined inside a GlobalVariables.cs. I figured it had to be stored in my database, so I've added a DbSet<GlobalVariables> to my ApplicationDbContext. If any of the global variables are updated, create a new record in the db. To get the current values, get the latest record (max id). Does this way of going about it make sense? I'm sure there are better ways 🙂
1 replies
CC#
Created by redfoxx on 11/4/2022 in #help
E-commerce suspend checkout while updating item price
In an e-commerce you update a shop item's price. This should of course be updated throughout the system, including carts with that item in them. How would I go about "suspending" cart checkout while prices are being updated? Just to be clear: The point is to ensure that the new prices are equally applied to everyone, and that the user is informed about the change before checking out! It could also be something other than item price, for instance delivery fees.
11 replies
CC#
Created by redfoxx on 11/4/2022 in #help
Global variables in .NET web application
What is a good way to define and use global variables in .NET web application? I have a simple e-commerce web app, and I have some variables that I want to use from inside any bounded context, all of which should be assigned a pre-defined value when building the app.
8 replies
CC#
Created by redfoxx on 10/24/2022 in #help
Save changes twice to db
Hi. I have a question about creating a new object, saving it to database, then changing some property to fire an event, and save to db again. I can't get it to work. My code goes like this: 1. Create a new Order 2. Set Order.Status = New 3. Save changes to db 4.Set Order.Status = Placed (event fires) 5. Save changes to db I've tried some various solutions out of desperation.. 🙂
3 replies
CC#
Created by redfoxx on 10/23/2022 in #help
Cannot retrieve updated object from context
2 replies