public IActionResult CustomerDetails() { ViewModelOrders model = new ViewModelOrders(); string customerName = HttpContext.Session.GetString("loginCustomer"); var Customer = _context.Kund.SingleOrDefault(n => n.AnvandarNamn == customerName); model.loggedCustomer = Customer; return(View(model)); }
public IActionResult CustomerDetails(ViewModelOrders model) { string customerName = HttpContext.Session.GetString("loginCustomer"); var Customer = _context.Kund.SingleOrDefault(n => n.AnvandarNamn == customerName); Customer.Email = model.loggedCustomer.Email; Customer.Gatuadress = model.loggedCustomer.Gatuadress; Customer.Postort = model.loggedCustomer.Postort; Customer.Postnr = model.loggedCustomer.Postnr; Customer.Telefon = model.loggedCustomer.Telefon; _context.SaveChanges(); return(View("Update")); }
public IActionResult Checkout() { ViewModelOrders orders = new ViewModelOrders(); var dishList = HttpContext.Session.GetString("selectedDishes"); if (dishList == null) { return(RedirectToAction("OrderingDishes")); } // TODO: check if dishlist is null List <Matratt> dishes = JsonConvert.DeserializeObject <List <Matratt> >(dishList); orders.orderedDishes = dishes; // all the orders will be in dishDetails return(View(orders)); }
public IActionResult OrderingDishes() { ViewModelOrders model = new ViewModelOrders(); string customerName = HttpContext.Session.GetString("loginCustomer"); var Customer = _context.Kund.SingleOrDefault(n => n.AnvandarNamn == customerName); model.loggedCustomer = Customer; Dictionary <string, List <Matratt> > dishDetails = new Dictionary <string, List <Matratt> >(); var types = _context.MatrattTyp.ToList(); foreach (var type in types) { var tempList = _context.Matratt.Where(p => p.MatrattTyp.Equals(type.MatrattTyp1)).ToList(); foreach (Matratt dish in tempList) { var productList = _context.MatrattProdukt.Where(p => p.MatrattId.Equals(dish.MatrattId)); StringBuilder ingredients = new StringBuilder(); foreach (MatrattProdukt product in productList) { Produkt ingredient = _context.Produkt.SingleOrDefault(p => p.ProduktId == product.ProduktId); ingredients.Append(ingredient.ProduktNamn); ingredients.Append(", "); } model.dishIngredients.Add(dish, ingredients.ToString()); } dishDetails.Add(type.Beskrivning, tempList); } model.dishByTypes = dishDetails; model.dishTypes = types; return(View(model)); }