public ActionResult <OffreEntite> Get(int id)
 {
     try
     {
         return(repo.GetById(id));
     }
     catch (InvalidOperationException e)
     {
         return(NotFound("Offre introuvable"));
     }
 }
Esempio n. 2
0
        /*public IActionResult Detail(int id)
         * {
         *  var chaineConnexion = @"Data Source = (LocalDB)\MSSQLLocalDB; AttachDbFilename = D:\Program .NET\Foofood-master\ExempleCours\ExempleCours\Data\Data.mdf; Integrated Security = True; Connect Timeout = 30";
         *
         *  try
         *  {
         *      using (var connection = new SqlConnection(chaineConnexion))
         *      {
         *          var galerie = connection.QueryFirst<OffreEntite>("SELECT * FROM Offre WHERE Id = @Id",new { Id = id });
         *
         *          return View(galerie);
         *
         *      } // Appel du Dispose de connection (ferme la connexion)
         *  }
         *  catch (SqlException e)
         *  {
         *      return RedirectToAction("Error", "Home");
         *  }
         * }*/

        //DETAIL DU PROF
        public IActionResult Detail(int id)
        {
            return(View(repo.GetById(id)));
        }