public async Task <IActionResult> Edit(int id, [Bind("Id,ApplicationUserId,ProductId,SweetenerId,SweetnessId,ToppingId,MilkTypeId,OriginId,IceCubeId,Notes")] CustomerPreferences customerPreferences) { if (id != customerPreferences.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(customerPreferences); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomerPreferencesExists(customerPreferences.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } var username = HttpContext.User.Identity.Name; if (!HttpContext.User.IsInRole(SD.Role_Admin)) { ViewData["ApplicationUserId"] = new SelectList(_context.ApplicationUsers.Where(x => x.UserName == username), "Id", "Name"); } else { ViewData["ApplicationUserId"] = new SelectList(_context.ApplicationUsers, "Id", "Name"); } ViewData["MilkTypeId"] = new SelectList(_context.MilkTypes, "Id", "MilkTypeName", customerPreferences.MilkTypeId); ViewData["ProductId"] = new SelectList(_context.Products, "Id", "Title", customerPreferences.ProductId); ViewData["SweetenerId"] = new SelectList(_context.Sweeteners, "Id", "SweetenerName", customerPreferences.SweetenerId); ViewData["SweetnessId"] = new SelectList(_context.Sweetness, "Id", "SweetnessName", customerPreferences.SweetnessId); ViewData["ToppingId"] = new SelectList(_context.Toppings, "Id", "ToppingName", customerPreferences.ToppingId); ViewData["OriginId"] = new SelectList(_context.Origins, "Id", "OriginName", customerPreferences.OriginId); ViewData["IceCubeId"] = new SelectList(_context.IceCubes, "Id", "IceCubeName", customerPreferences.IceCubeId); return(View(customerPreferences)); }
protected void Page_Load(object sender, EventArgs e) { selectShipping.IsLiveSite = IsLiveSite; selectPayment.IsLiveSite = IsLiveSite; if ((ShoppingCart != null) && (SiteContext.CurrentSite != null)) { if (ShoppingCart.CountryID == 0) { string countryName = ECommerceSettings.DefaultCountryName(SiteContext.CurrentSite.SiteName); CountryInfo ci = CountryInfoProvider.GetCountryInfo(countryName); ShoppingCart.CountryID = (ci != null) ? ci.CountryID : 0; } selectShipping.ShoppingCart = ShoppingCart; selectPayment.ShoppingCart = ShoppingCart; var customer = ShoppingCart.Customer; if (customer != null) { mPreferences = customer.GetPreferences(ShoppingCart.ShoppingCartSiteID); } } if (IsShippingNeeded) { if (!ShoppingCartControl.IsCurrentStepPostBack) { SelectShippingOption(); } } else { // Don't use shipping selection selectShipping.StopProcessing = true; // Hide title headTitle.Visible = false; // Change current checkout process step caption ShoppingCartControl.CheckoutProcessSteps[ShoppingCartControl.CurrentStepIndex].Caption = GetString("order_new.paymentshipping.titlenoshipping"); } }
// GET: Customer/CustomerPreferences/Create public IActionResult Create() { var username = HttpContext.User.Identity.Name; var userid = _context.ApplicationUsers.Where(x => x.UserName == username).FirstOrDefault().Id; ViewData["ApplicationUserId"] = new SelectList(_context.ApplicationUsers, "Id", "UserName"); ViewData["MilkTypeId"] = new SelectList(_context.MilkTypes, "Id", "MilkTypeName"); ViewData["ProductId"] = new SelectList(_context.Products, "Id", "Title"); ViewData["SweetenerId"] = new SelectList(_context.Sweeteners, "Id", "SweetenerName"); ViewData["SweetnessId"] = new SelectList(_context.Sweetness, "Id", "SweetnessName"); ViewData["ToppingId"] = new SelectList(_context.Toppings, "Id", "ToppingName"); ViewData["OriginId"] = new SelectList(_context.Origins, "Id", "OriginName"); ViewData["IceCubeId"] = new SelectList(_context.IceCubes, "Id", "IceCubeName"); if (!HttpContext.User.IsInRole(SD.Role_Admin)) { ViewData["ApplicationUserId"] = new SelectList(_context.ApplicationUsers.Where(x => x.UserName == username), "Id", "Name"); CustomerPreferences customerPreferences = new CustomerPreferences(); customerPreferences.ApplicationUserId = userid; return(View(customerPreferences)); } return(View()); }
private IEnumerable <MatrixCase> ValidRules(CustomerPreferences customerPreferences, IReadOnlyList <MatrixCase> matrix) => matrix.Where(rule => rule.IsYourLaptopFast == customerPreferences.IsYourLaptopFast && rule.IsYourCarTurboCharged == customerPreferences.IsYourCarTurboCharged);