public ActionResult EditConfig(int?id) { StoreFrontConfiguration config = GetConfigAndAccessCheck(id); if (config == null) { return(HttpBadRequest("No config found for store front config id [" + (id ?? 0) + "]")); } Cart cart = config.StoreFront.GetPreviewCart(Session.SessionID, 1, null, CurrentUserProfileOrNull); CartConfigViewModel cartConfig = config.CartConfigViewModel(false, false); ViewData.Add("CartConfig", cartConfig); ViewData.Add("IsEditConfig", true); return(View("Index", cart)); }
public ActionResult PreviewUpdateQty(int?id, string discountCode, int?quantity) { StoreFrontConfiguration config = GetConfigAndAccessCheck(id); if (config == null) { return(HttpBadRequest("No config found for store front config id [" + (id ?? 0) + "]")); } if (!quantity.HasValue) { quantity = 1; } Cart cart = config.StoreFront.GetPreviewCart(Session.SessionID, quantity.Value, discountCode, CurrentUserProfileOrNull); CartConfigViewModel cartConfig = config.CartConfigViewModel(false, false); ViewData.Add("CartConfig", cartConfig); ViewData.Add("IsPreview", true); return(View("Index", cart)); }
public ActionResult EditConfig(int?id, CartConfigViewModel config) { if (!id.HasValue) { return(HttpBadRequest("store front config id (ID) is null")); } if (id.Value != config.StoreFrontConfigurationId) { return(HttpBadRequest("store front configuration id mismatch. Url id: " + id.Value + " view model value: " + config.StoreFrontConfigurationId)); } StoreFrontConfiguration configToEdit = GetConfigAndAccessCheck(id); if (config == null) { return(HttpBadRequest("No config found for store front config id [" + (id ?? 0) + "]")); } if (ModelState.IsValid) { configToEdit.CopyValuesFromCartConfigViewModel(config); GStoreDb.StoreFrontConfigurations.Update(configToEdit); GStoreDb.SaveChanges(); AddUserMessage("Cart Configuration updated.", "Your changes have been saved for configuration '" + configToEdit.ConfigurationName.ToHtml() + "' [" + configToEdit.StoreFrontConfigurationId + "]", UserMessageType.Success); return(RedirectToAction("Preview", new { id = configToEdit.StoreFrontConfigurationId })); } AddUserMessage("Form Error.", "There was an error in your form values. Please correct the error below.", UserMessageType.Warning); Cart cart = configToEdit.StoreFront.GetPreviewCart(Session.SessionID, 1, null, CurrentUserProfileOrNull); CartConfigViewModel cartConfig = configToEdit.CartConfigViewModel(false, false); ViewData.Add("CartConfig", cartConfig); ViewData.Add("IsEditConfig", true); return(View("Index", cart)); }