got a tricky one here me thinks!
I want to understand how if this Cart object gets passed by value using the model binder, then how can it effect the actual value in the session?
public RedirectToRouteResult AddToCart(Cart cart, int productId, string returnUrl) {
Product product = repository.Products
.FirstOrDefault(p => p.ProductID == productId);
if (product != null) {
cart.AddItem(product, 1);
}
return RedirectToAction("Index", new { returnUrl });
}
Hope this explains my issue!
Thanks for any assistance
details
this bold code doesn't effect the customprofile in session
[AllowAnonymous]
[HttpPost]
public ActionResult Register(RegisterModel model, CustomProfile customProfile)
{
if (User.Identity.IsAuthenticated)
return RedirectToAction("Index", "Home");
if (ModelState.IsValid)
{
// Attempt to register the user
MembershipCreateStatus createStatus;
membershipProvider.CreateUser(model, null, null, true, null,
out createStatus);
if (createStatus == MembershipCreateStatus.Success)
{
const string message = "You have successfully reigestered, and you are now logged in.";
authProvider.SetAuthCookie(model.UserName, false /* createPersistentCookie */);
var newCustomProfile = new CustomProfile(model.UserName);
var db = new CrowdFundingDB();
**customProfile = customProfileProvider.Create(newCustomProfile);**