public GuardarRestauranteResponse Guardar(Restaurante restaurante) { try { restaurante.Evaluacio(); _conexion.Open(); _repositorio.Guardar(restaurante); _conexion.Close(); return(new GuardarRestauranteResponse(restaurante)); } catch (Exception e) { return(new GuardarRestauranteResponse($"Error de la Aplicacion: {e.Message}")); } finally { _conexion.Close(); } }
public GuardarRestauranteResponse Guardar(Restaurante restaurante) { try { var res = _context.Restaurantes.Find(restaurante.Nit); if (res != null) { return(new GuardarRestauranteResponse("Error el Restaurante ya se encuentra registrado")); } restaurante.Evaluacio(); _context.Restaurantes.Add(restaurante); _context.SaveChanges(); return(new GuardarRestauranteResponse(restaurante)); } catch (Exception e) { return(new GuardarRestauranteResponse($"Error de la Aplicacion: {e.Message}")); } }