示例#1
0
        public IActionResult Editar(RestauranteViewModel model)
        {
            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("", "Te hacen falta campos");
                return(View(model));
            }

            var restaurante = _restauranteService.Obtener(model.Id);

            restaurante.Nombre = model.Nombre;

            _restauranteService.Editar(restaurante);

            return(RedirectToAction("Index"));
        }
示例#2
0
        public ActionResult Put(int id, RestauranteViewModel model)
        {
            var restaurante = _restauranteService.Obtener(id);

            if (restaurante == null)
            {
                return(BadRequest());
            }

            restaurante.Nombre    = model.Nombre;
            restaurante.PaginaWeb = model.PaginaWeb;
            restaurante.Telefono  = int.Parse(model.Telefono);

            _restauranteService.Editar(restaurante);

            return(Ok());
        }