示例#1
0
 public IHttpActionResult Get(int id)
 {
     try
     {
         var even = db.Evenements.Find(id);
         if (even == null)
         {
             return(NotFound());
         }
         var            request = HttpContext.Current.Request;
         var            baseUrl = request.Url.Scheme + "://" + request.Url.Authority;
         EvenementsList evn     = new EvenementsList()
         {
             ID          = even.ID,
             Titre_even  = even.Titre_even,
             Description = even.Description,
             Date_debut  = even.Date_debut.Value,
             Date_fin    = even.Date_fin.Value,
             ImageUrl    = baseUrl + "/AppImg/" + even.Image
         };
         return(Ok(evn));
     }
     catch (Exception)
     {
         return(BadRequest());
     }
 }
示例#2
0
 public IHttpActionResult GetEvenements()
 {
     try
     {
         var events  = db.Evenements.Where(e => e.Statut == true).ToList();
         var request = HttpContext.Current.Request;
         var baseUrl = request.Url.Scheme + "://" + request.Url.Authority;
         List <EvenementsList> evn = new List <EvenementsList>();
         foreach (var even in events)
         {
             EvenementsList evenements = new EvenementsList
             {
                 ID          = even.ID,
                 Titre_even  = even.Titre_even,
                 Description = even.Description,
                 Date_debut  = even.Date_debut.Value,
                 Date_fin    = even.Date_fin.Value,
                 ImageUrl    = baseUrl + "/AppImg/" + even.Image
             };
             evn.Add(evenements);
         }
         return(Ok(evn));
     }
     catch (Exception)
     {
         return(BadRequest());
     }
 }