-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AddToCart return Redirect(TempData["returnURL"].ToString()); #3
Comments
Since you are not pushing any values to the TempData["returnURL"], you are getting null reference exception. You can use |
Can you help me how to connect the db with the project or how to get started with the project. I didn't know R49_MyEcommerceDB file and MyEcommerceDbContext is the same? I have restored R49_MyEcommerceDB in sql server; add new model of data with R49_MyEcommerceDB in visual studio but can't not run. It has the error like this System.Data.Entity.ModelConfiguration.ModelValidationException: 'One or more validation errors were detected during model generation: MyEcommerceAdmin.Models.admin_Employee: : EntityType 'admin_Employee' has no key defined. Define the key for this EntityType. |
In Product1Controller
I get the error so How to fixed and why this error
Can you explain me sir.
public ActionResult AddToCart(int id)
{
OrderDetail OD = new OrderDetail();
OD.ProductID = id;
int Qty = 1;
decimal price = db.Products.Find(id).UnitPrice;
OD.Quantity = Qty;
OD.UnitPrice = price;
OD.TotalAmount = Qty * price;
OD.Product = db.Products.Find(id);
System.NullReferenceException: 'Object reference not set to an instance of an object.'
System.Web.Mvc.TempDataDictionary.this[string].get returned null.
The text was updated successfully, but these errors were encountered: