Esempio n. 1
0
        public async Task <IActionResult> Create([Bind("Id,Name,Description")] Cuisine cuisine)
        {
            if (ModelState.IsValid)
            {
                _context.Add(cuisine);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(cuisine));
        }
Esempio n. 2
0
        public async Task <IActionResult> Create([Bind("Id,Name,Price,Description,CuisineId")] FoodItem foodItem)
        {
            if (ModelState.IsValid)
            {
                _context.Add(foodItem);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CuisineId"] = new SelectList(_context.Cuisines, "Id", "Name", foodItem.CuisineId);
            return(View(foodItem));
        }
        public async Task <IActionResult> Create([Bind("Id,Name,Address,Contact_Number,CuisineId,FoodItemId")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                _context.Add(customer);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CuisineId"]  = new SelectList(_context.Cuisines, "Id", "Name", customer.CuisineId);
            ViewData["FoodItemId"] = new SelectList(_context.FoodItems.Where(x => x.CuisineId == customer.CuisineId), "Id", "Name", customer.FoodItemId);
            return(View(customer));
        }