public HttpResponseMessage ListeConsultant() { try { webService.DynmixProcessMangWS services = new DynmixProcessMangWS(); webService.RootCons Consultant = new RootCons(); services.Credentials = new System.Net.NetworkCredential("mhh", "Dynamix@2019", "DYS"); //string text = services.ListeConsultant(); var response = new HttpResponseMessage(HttpStatusCode.OK); services.ListeConsultant(ref Consultant); int i = 0; string id; string nom; string prenom; string cin; string allJson = "["; int j = Consultant.RecCons.Length; while (i < j) { nom = Consultant.RecCons[i].nom.ToString(); id = Consultant.RecCons[i].id.ToString(); prenom = Consultant.RecCons[i].prenom.ToString(); cin = Consultant.RecCons[i].cin.ToString(); allJson += "{ \"id\": " + "\"" + id + "\"," + "\"nom\": " + "\"" + nom + "\"," + "\"prenom\": " + "\"" + prenom + "\"," + "\"cin\": " + "\"" + cin + "\"}"; if (i != j - 1) { allJson += ","; } i = i + 1; } allJson += " ]"; response.Content = new StringContent(allJson); //responce.Content= new str return(response); } catch (Exception e) { var responce = new HttpResponseMessage(HttpStatusCode.OK); responce.Content = new StringContent("{'Error machekell':'" + e.Message.Replace('\'', '"') + "'}"); return(responce); } }
public HttpResponseMessage UpdateConsu(int id, string nom, string prenom) { try { webService.DynmixProcessMangWS services = new DynmixProcessMangWS(); webService.RootCons Consultant = new RootCons(); services.Credentials = new System.Net.NetworkCredential("mhh", "Dynamix@2019", "DYS"); //string text = services.ListeConsultant(); var response = new HttpResponseMessage(HttpStatusCode.OK); services.UpdateConsu(id, nom, prenom); response.Content = new StringContent(allJson); //responce.Content= new str return(response); } catch (Exception e) { var responce = new HttpResponseMessage(HttpStatusCode.OK); responce.Content = new StringContent("{'Error machekell':'" + e.Message.Replace('\'', '"') + "'}"); return(responce); } }