示例#1
0
        public HttpResponseMessage GetDoctorBySpecialite([FromUri] string specialte = "All")
        {
            using (USERSDBEntities entities = new USERSDBEntities())
            {
                switch (specialte.ToLower())
                {
                case "All":
                    return(Request.CreateResponse(HttpStatusCode.OK, entities.Doctors.ToList()));

                case "pediatre":
                    return(Request.CreateResponse(HttpStatusCode.OK,
                                                  entities.Doctors.Where(e => e.SPECIALITE.ToLower() == "Pediatre ").ToList()));

                case "gynecologue":
                    return(Request.CreateResponse(HttpStatusCode.OK,
                                                  entities.Doctors.Where(e => e.SPECIALITE.ToLower() == "Gynecologue ").ToList()));

                case "general":
                    return(Request.CreateResponse(HttpStatusCode.OK,
                                                  entities.Doctors.Where(e => e.SPECIALITE.ToLower() == "General ").ToList()));

                case "psycologue":
                    return(Request.CreateResponse(HttpStatusCode.OK,
                                                  entities.Doctors.Where(e => e.SPECIALITE.ToLower() == "Psycologue ").ToList()));

                default:
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest,
                                                       "Merci de choisir une specialte parmis la liste"));
                }
            }
        }
示例#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));
            }
        }
示例#3
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));
            }
        }
示例#4
0
 public IEnumerable <RDV> Get()
 {
     using (USERSDBEntities entities = new USERSDBEntities())
     {
         return(entities.RDVs.ToList());
     }
 }
示例#5
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));
            }
        }
示例#6
0
 public IEnumerable <Aviss> Get()
 {
     using (USERSDBEntities entities = new USERSDBEntities())
     {
         return(entities.Avisses.ToList());
     }
 }
示例#7
0
 public static bool Login(string username, string mdp)
 {
     using (USERSDBEntities entities = new USERSDBEntities())
     {
         return(entities.Admins.Any(Admin => Admin.A_LOGIN.Equals(
                                        username, StringComparison.OrdinalIgnoreCase) && Admin.A_MDP == mdp));
     }
 }
示例#8
0
 public static bool Login(string username, string mdp)
 {
     using (USERSDBEntities entities = new USERSDBEntities())
     {
         return(entities.Users.Any(User => User.EMAIL.Equals(
                                       username, StringComparison.OrdinalIgnoreCase) && User.MDP == mdp));
     }
 }
示例#9
0
        public HttpResponseMessage Get()
        {
            string username = Thread.CurrentPrincipal.Identity.Name;

            using (USERSDBEntities entities = new USERSDBEntities())
            {
                var entity  = entities.Users.FirstOrDefault(e => e.EMAIL == username);
                int id_user = entity.ID;

                return(Request.CreateResponse(HttpStatusCode.OK,
                                              entities.RDVs.Where(e => e.ID_User == id_user).ToList()));
            }
        }
示例#10
0
 public HttpResponseMessage Get(int id)
 {
     using (USERSDBEntities entities = new USERSDBEntities())
     {
         var entity = entities.Users.FirstOrDefault(e => e.ID == id);
         if (entity != null)
         {
             return(Request.CreateResponse(HttpStatusCode.OK, entity));
         }
         else
         {
             return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "User with ID = " + id.ToString() + " not found"));
         }
     }
 }
示例#11
0
 public HttpResponseMessage Get(int id)
 {
     using (USERSDBEntities entities = new USERSDBEntities())
     {
         var entity = entities.RDVs.FirstOrDefault(e => e.ID_User == id);
         if (entity != null)
         {
             var doc_entity = entities.Doctors.FirstOrDefault(e => e.ID == entity.ID_Doctor);
             return(Request.CreateResponse(HttpStatusCode.OK, new { entity, doc_entity }));
         }
         else
         {
             return(Request.CreateErrorResponse(HttpStatusCode.NotFound, " RDV with ID = " + id.ToString() + " not found"));
         }
     }
 }
示例#12
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));
            }
        }
示例#13
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));
     }
 }