示例#1
0
 // variabiliser cette partie.
 public ChoiceTypeDb(string type)
 {
     if ("mysql".Equals(type))
     {
         isql = new MysqlDb();
     }
 }
示例#2
0
        public IActionResult searchCandidateMobile(string name, string token)
        {
            try{
                IsqlMethod isql          = Factory.Factory.GetSQLInstance("mysql");
                ArrayList  candidatListe = null;
                if (isql.UserCanRead(token))
                {
                    candidatListe = isql.searchCandidateMobile(name, token);
                }
                else
                {
                    throw new Exception("Vous n'avez pas le droit de lecture");
                }
                return(new ObjectResult(candidatListe));
            }catch (Exception exception) {
                new WsCustomeException(this.GetType().Name, exception.Message);
                ArrayList errorList = new ArrayList();
                errorList.Add(new State()
                {
                    code = 3, content = exception.Message, success = false
                });

                return(CreatedAtRoute("GetErrors", new { error = errorList }, errorList));
            }
        }
示例#3
0
 public IActionResult  GetAuthentification([FromBody] User user)
 {
     try{
         checkUser(user);
         IsqlMethod isql = Factory.Factory.GetSQLInstance("mysql");
         isql.Authentification(user.email, user.password);
         User newUser = isql.GenerateToken();
         if (!isql.verifyTheTokenExist(newUser.sessionId))
         {
             isql.addTokenToUser(newUser.sessionId, user.email);
             newUser.email = user.email;
         }
         else
         {
             throw new Exception("Le token de l'utilisateur existe deja");
         }
         return(new ObjectResult(newUser));
     }catch (Exception exc) {
         new WsCustomeException(this.GetType().Name, exc.Message);
         State state = new State()
         {
             code = 1, content = exc.Message, success = false
         };
         return(CreatedAtRoute("GetNote", new { error = state }, state));
     }
 }
示例#4
0
 public IActionResult UpdateReportCandidat([FromBody] Report report)
 {
     try{
         checkReport(report);
         IsqlMethod isql = Factory.Factory.GetSQLInstance("mysql");
         isql.UserCanUpdate(report.sessionId);
         int idCandidat = isql.getIdFromCandidateEmail(report.emailCandidat);
         if (!isql.reportAlreadyExist(idCandidat))
         {
             throw new Exception("Le report n'existe pas, vous devez le creer au prealable");
         }
         isql.updateReport(report, idCandidat);
         return(new ObjectResult(new State()
         {
             code = 3, content = "Le report a ete modifie parfaitement à votre system", success = true
         }));
     }catch (Exception exc) {
         new WsCustomeException(this.GetType().Name, exc.Message);
         State state = new State()
         {
             code = 1, content = exc.Message, success = false
         };
         return(CreatedAtRoute("GetNote", new { error = state }, state));
     }
 }
示例#5
0
 public IActionResult updateCandidat([FromBody] Candidat candidat)
 {
     try{
         checkCandidat(candidat);
         IsqlMethod isql = Factory.Factory.GetSQLInstance("mysql");
         isql.UserCanUpdate(candidat.session_id);
         if (!isql.CandidatAlreadyExist(candidat))
         {
             throw new Exception("Le candidat n'est pas existant dans votre systeme, veuillez le creer");
         }
         int idUser     = isql.getIdFromToken(candidat.session_id);
         int idCandidat = isql.getIdFromCandidateEmail(candidat.emailAdress);
         isql.updateCandidate(candidat, idUser);
         isql.typeAction(candidat.action, candidat.independant, DateTime.Now, idCandidat, "UPDATE");
         return(new ObjectResult(new State()
         {
             code = 4, content = "Le candidat a ete modifie dans votre systeme", success = true
         }));
     }catch (Exception exc) {
         new WsCustomeException(this.GetType().Name, exc.Message);
         State state = new State()
         {
             code = 1, content = exc.Message, success = false
         };
         return(CreatedAtRoute("GetNote", new { error = state }, state));
     }
 }