예제 #1
0
 public IActionResult Save([FromBody] restaurante restaurante)
 {
     try
     {
         if (ModelState.IsValid)
         {
             _svc.Add(restaurante);
             return(new CreatedAtRouteResult("Restaurante salvo com sucesso!", new { id = restaurante.id, url = "api/restaurante/" + restaurante.id }));
         }
         return(BadRequest(ModelState));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
예제 #2
0
 public IActionResult Save([FromBody] ApplicationCore.Entity.Restaurante restaurante)
 {
     try
     {
         if (ModelState.IsValid)
         {
             _restauranteService.Add(restaurante);
             return(new OkObjectResult(restaurante));
             //return new CreatedAtRouteResult("Sucesso!", new { id = restaurante.Id });
         }
         return(BadRequest(ModelState.ValidationState));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }