public static void Update(int myId, string mail, string pass, string nik, string firsname, string lastname, string name, int complexion, int nivel, double weight, double height) { //ACTUALIZANDO DATOS NO SE PERMITE CAMBIA FECHA DE NACIMIENTO NI SEXO //los q son int los valido antes de enviar para mandarlos de acuerdo al num q corresponda //tbn al momento de enviar para guardar mandar como tipo int a: complexion y nivel HttpClient client = new HttpClient(); MyGym.Common2.Enum.ComplexionFisica compl = MyGym.Common2.Enum.ComplexionFisica.Pequena; if (complexion == 1) { compl = MyGym.Common2.Enum.ComplexionFisica.Mediana; } if (complexion == 2) { compl = MyGym.Common2.Enum.ComplexionFisica.Grande; } MyGym.Common2.Enum.Nivel niv = MyGym.Common2.Enum.Nivel.MuyLeve; if (nivel == 1) { niv = MyGym.Common2.Enum.Nivel.Leve; } if (nivel == 2) { niv = MyGym.Common2.Enum.Nivel.Moderado; } if (nivel == 3) { niv = MyGym.Common2.Enum.Nivel.Intenso; } if (nivel == 4) { niv = MyGym.Common2.Enum.Nivel.Excepcional; } UserInformation user = new UserInformation() { UserID = myId, Email = mail, FirstName = firsname, Height = height, LastName = lastname, LevelActivity = niv, Names = name, Nick = nik, Password = pass, PhysicalComplexion = compl, Weight = weight }; client.BaseAddress = new Uri("http://localhost:5638"); var content = new FormUrlEncodedContent(new[] { new KeyValuePair <string, string> ("userdata", JsonConvert.SerializeObject(user)) }); var result = client.PostAsync("/User/Update ", content).Result; string jsonresult = result.Content.ReadAsStringAsync().Result; }
public static void Register(string mail, string pass, string nik, string firsname, string lastname, string name, int sex, int complexion, int nivel, double weight, double height, DateTime dateofbirt) { //REGISTRO DE UN NUEVO USUARIO //los q son int los valido antes de enviar para mandarlos de acuerdo al num q corresponda //tbn al momento de enviar para guardar mandar como tipo int a sexo, complexion y nivel HttpClient client = new HttpClient(); MyGym.Common2.Enum.ComplexionFisica compl = MyGym.Common2.Enum.ComplexionFisica.Pequena; if (complexion == 1) { compl = MyGym.Common2.Enum.ComplexionFisica.Mediana; } if (complexion == 2) { compl = MyGym.Common2.Enum.ComplexionFisica.Grande; } MyGym.Common2.Enum.Nivel niv = MyGym.Common2.Enum.Nivel.MuyLeve; if (nivel == 1) { niv = MyGym.Common2.Enum.Nivel.Leve; } if (nivel == 2) { niv = MyGym.Common2.Enum.Nivel.Moderado; } if (nivel == 3) { niv = MyGym.Common2.Enum.Nivel.Intenso; } if (nivel == 4) { niv = MyGym.Common2.Enum.Nivel.Excepcional; } MyGym.Common2.Enum.Sexo sexx = MyGym.Common2.Enum.Sexo.Femenino; if (sex == 1) { sexx = MyGym.Common2.Enum.Sexo.Masculino; } UserInformation user = new UserInformation() { DateOfBirth = dateofbirt, Email = mail, FirstName = firsname, Height = height, LastName = lastname, LevelActivity = niv, Names = name, Nick = nik, Password = pass, PhysicalComplexion = compl, Sex = sexx, Weight = weight }; string json = JsonConvert.SerializeObject(user); client.BaseAddress = new Uri("http://localhost:5638"); var content = new FormUrlEncodedContent(new[] { new KeyValuePair <string, string> ("userdata", json) }); var result = client.PostAsync("/User/Register", content).Result; string jsonresult = result.Content.ReadAsStringAsync().Result; }