Exemplo n.º 1
0
        public HttpResponseMessage Put(int id, [FromBody] Doctor D)
        {
            try
            {
                using (USERSDBEntities entities = new USERSDBEntities())
                {
                    var entity = entities.Doctors.FirstOrDefault(e => e.ID == id);
                    if (entity == null)
                    {
                        return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Doctor  with ID = " + id.ToString() + " not found"));
                    }
                    else
                    {
                        entity.NOM        = D.NOM;
                        entity.PRENOM     = D.PRENOM;
                        entity.SPECIALITE = D.SPECIALITE;
                        entity.EMAIL      = D.EMAIL;
                        entity.TEL        = D.TEL;

                        entities.SaveChanges();

                        return(Request.CreateResponse(HttpStatusCode.OK, entity));
                    }
                }
            }
            catch (Exception e)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, e));
            }
        }
Exemplo n.º 2
0
        public HttpResponseMessage Put(int id, [FromBody] RDV V)
        {
            try
            {
                using (USERSDBEntities entities = new USERSDBEntities())
                {
                    var entity = entities.RDVs.FirstOrDefault(e => e.ID == id);
                    if (entity == null)
                    {
                        return(Request.CreateErrorResponse(HttpStatusCode.NotFound, " with ID = " + id.ToString() + " not found"));
                    }
                    else
                    {
                        entity.ETAT  = V.ETAT;
                        entity.DATER = V.DATER;
                        entities.SaveChanges();

                        return(Request.CreateResponse(HttpStatusCode.OK, entity));
                    }
                }
            }
            catch (Exception e)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, e));
            }
        }
Exemplo n.º 3
0
        public HttpResponseMessage Put(int id, [FromBody] Aviss A)
        {
            try
            {
                using (USERSDBEntities entities = new USERSDBEntities())
                {
                    var entity = entities.Avisses.FirstOrDefault(e => e.ID == id);
                    if (entity == null)
                    {
                        return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Avis with ID = " + id.ToString() + " not found"));
                    }
                    else
                    {
                        entity.NOTE_ACCUEIL      = A.NOTE_ACCUEIL;
                        entity.NOTE_DIAG         = A.NOTE_DIAG;
                        entity.NOTE_FACIL        = A.NOTE_FACIL;
                        entity.NOTE_PROMPATITUDE = A.NOTE_PROMPATITUDE;
                        entity.NOTE_RECOM        = A.NOTE_RECOM;

                        entities.SaveChanges();

                        return(Request.CreateResponse(HttpStatusCode.OK, entity));
                    }
                }
            }
            catch (Exception e)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, e));
            }
        }
Exemplo n.º 4
0
        /*public HttpResponseMessage GetDoctorByname(String name)
         * {
         *  using (USERSDBEntities entities = new USERSDBEntities())
         *  {
         *      var entity = entities.Doctors.FirstOrDefault(e => e.NOM == name);
         *      if (entity != null)
         *      {
         *          return Request.CreateResponse(HttpStatusCode.OK, entity);
         *      }
         *      else
         *      {
         *          return Request.CreateErrorResponse(HttpStatusCode.NotFound, "Doctor with ID = " + name + " not found");
         *      }
         *  }
         * }*/
        /*[HttpGet]
         * public HttpResponseMessage Specialite()
         * {
         *  using (USERSDBEntities entities = new USERSDBEntities())
         *  {
         *      //.Country.Select(c => c.NameofCountry).ToListAsync();
         *      //var entity = entities.RDVs.FirstOrDefault(e => e.ID == id);
         *      var entity = entities.Doctors.Select(e => e.SPECIALITE).ToList();
         *      if(entity != null)
         *      {
         *          return Request.CreateResponse(HttpStatusCode.OK, entity);
         *      }
         *      return Request.CreateErrorResponse(HttpStatusCode.NotFound, "User with ID = ");
         *
         *  }
         * }*/
        public HttpResponseMessage Post([FromBody] Doctor D)
        {
            try
            {
                using (USERSDBEntities entities = new USERSDBEntities())
                {
                    entities.Doctors.Add(D);
                    entities.SaveChanges();

                    var message = Request.CreateResponse(HttpStatusCode.Created, D);
                    message.Headers.Location = new Uri(Request.RequestUri + "/" + D.ID.ToString());
                    return(message);
                }
            }
            catch (Exception e)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, e));
            }
        }
Exemplo n.º 5
0
 public HttpResponseMessage Delete(int id)
 {
     try {
         using (USERSDBEntities entities = new USERSDBEntities())
         {
             var entity = entities.Users.FirstOrDefault(e => e.ID == id);
             if (entity == null)
             {
                 return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "User with ID = " + id.ToString() + " not found"));
             }
             else
             {
                 entities.Users.Remove(entity);
                 entities.SaveChanges();
                 return(Request.CreateResponse(HttpStatusCode.OK));
             }
         }
     } catch (Exception e) {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, e));
     }
 }