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)); }
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)); }
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)); }
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)); }
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)); }