public async Task <IActionResult> Create([Bind("Id,title,price,color,proof,category")] Cocktail cocktail, string[] selectedProducts, string create, string preview) { if (create != null) { if (ModelState.IsValid) { CreateCocktailProducts(selectedProducts, cocktail); _context.Add(cocktail); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } if (preview != null) { cocktail.color = ColorTranslator.ToHtml(CalculateColorFromProducts(selectedProducts)); return(View(cocktail)); } return(View(cocktail)); }
public async Task <IActionResult> Create([Bind("Id,title,units,color,description")] Product product) { if (ModelState.IsValid) { _context.Add(product); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(product)); }
public async Task <IActionResult> Create([Bind("Id,full_price,userId")] Cart cart) { if (ModelState.IsValid) { _context.Add(cart); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["userId"] = new SelectList(_context.User, "Id", "Id", cart.userId); return(View(cart)); }
public async Task <IActionResult> Create([Bind("Id,count,price,cartId,cocktailId")] CartItem cartItem) { if (ModelState.IsValid) { _context.Add(cartItem); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["cartId"] = new SelectList(_context.Cart, "Id", "Id", cartItem.cartId); ViewData["cocktailId"] = new SelectList(_context.Cocktail, "Id", "Id", cartItem.cocktailId); return(View(cartItem)); }
public async Task <IActionResult> Create([Bind("Id,unit,quantity,cocktailId,productId")] CocktailProduct cocktailProduct) { if (ModelState.IsValid) { _context.Add(cocktailProduct); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["cocktailId"] = new SelectList(_context.Cocktail, "Id", "Id", cocktailProduct.cocktailId); ViewData["productId"] = new SelectList(_context.Product, "Id", "Id", cocktailProduct.productId); return(View(cocktailProduct)); }
public async Task <ActionResult> Register(RegistrationViewModel model) { if (ModelState.IsValid) { User user = new User { login = model.login, first_name = model.first_name, last_name = model.last_name, email = model.email, password = model.password, role = 0 }; _context.Add(user); await _context.SaveChangesAsync(); } else { return(View("Registration")); } return(RedirectToAction("Index", "Home")); }