public ActionResult Create(EditPlateModelView modelView)
        {
            if (!ModelState.IsValid)
            {
                var restaurant = _restaurantRepository.Get();
                modelView.RestaurantOptions = new SelectList(restaurant, "Id", "Name");
                return(View(modelView));
            }

            var plate = new Plate
            {
                Id           = modelView.Id,
                Name         = modelView.NamePlate,
                Ingredients  = modelView.Ingredients,
                RestaurantId = modelView.RestaurantId
            };

            try
            {
                _plateRepository.Create(plate);
            }
            catch (Exception ex)
            {
                //ModelState.AddModelError("message", ex.Message);
                var restaurant = _restaurantRepository.Get();
                modelView.RestaurantOptions = new SelectList(restaurant, "Id", "Name");
                return(View(modelView));
            }
            return(RedirectToAction("Index"));
        }
        public ActionResult Delete(int id)
        {
            var plateModel = _plateRepository.Get(id);
            var plateView  = new EditPlateModelView
            {
                Id           = plateModel.Id,
                NamePlate    = plateModel.Name,
                Ingredients  = plateModel.Ingredients,
                RestaurantId = plateModel.RestaurantId
            };

            return(View(plateView));
        }
        public ActionResult Create()
        {
            var restaurant = _restaurantRepository.Get();
            var plateView  = new EditPlateModelView
            {
                Id                = 0,
                NamePlate         = "",
                Ingredients       = "",
                RestaurantId      = 0,
                RestaurantOptions = new SelectList(restaurant, "Id", "Name")
            };

            return(View(plateView));
        }
        public ActionResult Edit(int id)
        {
            var restaurant = _restaurantRepository.Get();
            var plate      = _plateRepository.Get(id);
            var plateView  = new EditPlateModelView
            {
                Id                = plate.Id,
                NamePlate         = plate.Name,
                Ingredients       = plate.Ingredients,
                RestaurantId      = plate.RestaurantId,
                RestaurantOptions = new SelectList(restaurant, "Id", "Name")
            };

            return(View(plateView));
        }
        public ActionResult Edit(EditPlateModelView modelView)
        {
            var plate = new Plate
            {
                Id           = modelView.Id,
                Name         = modelView.NamePlate,
                RestaurantId = modelView.RestaurantId,
                Ingredients  = modelView.Ingredients
            };

            if (_plateRepository.Update(plate))
            {
                return(RedirectToAction("Index"));
            }

            return(View(modelView));
        }