Exemple #1
0
        public async Task <IActionResult> Create([Bind("Id,Name,Info")] Type @type)
        {
            if (ModelState.IsValid)
            {
                _context.Add(@type);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(@type));
        }
Exemple #2
0
        public async Task <IActionResult> Create([Bind("Id,Name,Post,Address")] Client client)
        {
            if (ModelState.IsValid)
            {
                _context.Add(client);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(client));
        }
Exemple #3
0
        public async Task <IActionResult> Create([Bind("Id,Name")] Restaurant restaurant)
        {
            if (ModelState.IsValid)
            {
                _context.Add(restaurant);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(restaurant));
        }
        public async Task <IActionResult> Create(int dishId, [Bind("Id,DishId,IngredientId")] DishIngredient dishIngredient)
        {
            dishIngredient.DishId = dishId;
            if (ModelState.IsValid)
            {
                _context.Add(dishIngredient);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index", "DishIngredients", new { id = dishId, name = _context.Dish.Where(c => c.Id == dishId).FirstOrDefault().Name }));
            }
            return(View(dishIngredient));
        }
Exemple #5
0
        public async Task <IActionResult> Create(int restaurantId, [Bind("Id,RestaurantId,Address,OpeningTime,ClosingTime")] RestaurantLocation restaurantLocation)
        {
            restaurantLocation.RestaurantId = restaurantId;
            if (ModelState.IsValid)
            {
                _context.Add(restaurantLocation);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index", "RestaurantLocations", new { id = restaurantId, name = _context.Restaurant.Where(c => c.Id == restaurantId).FirstOrDefault().Name }));
            }
            return(View(restaurantLocation));
        }
Exemple #6
0
        public async Task <IActionResult> Create(int typeId, [Bind("Id,RestaurantId,Name,TypeId,Recipe,Calories,Cost")] Dish dish)
        {
            dish.TypeId = typeId;
            if (ModelState.IsValid)
            {
                _context.Add(dish);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index", "Dishes", new { id = typeId, name = _context.Type.Where(c => c.Id == typeId).FirstOrDefault().Name }));
            }
            return(View(dish));
        }