public static bool updateUserAttribute(PersonalAttributeDTOmin pUserAttribute) { using (SqlConnection connection = new SqlConnection(WebConfigurationManager.ConnectionStrings["connectionRRHHDatabase"].ConnectionString)) { SqlCommand command = new SqlCommand("usp_update_userAttribute", connection); command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.Add("@id_attribute", SqlDbType.Int); command.Parameters["@id_attribute"].Value = pUserAttribute.attribute_id; command.Parameters.Add("@value", SqlDbType.NVarChar); command.Parameters["@value"].Value = pUserAttribute.value; command.Parameters.Add("@id_user", SqlDbType.Int); command.Parameters["@id_user"].Value = pUserAttribute.user_id; command.Parameters.Add("@userLog", SqlDbType.Int); command.Parameters["@userLog"].Value = pUserAttribute.userLog; command.Connection.Open(); int result = command.ExecuteNonQuery(); if (result != 0) { return(true); } }; return(false); }
public static List <PersonalAttributeDTOmin> getUserAttributesbyCatgorie(string id_user, string id_categorie) { List <PersonalAttributeDTOmin> personaAttributeList = new List <PersonalAttributeDTOmin>(); using (SqlConnection connection = new SqlConnection(WebConfigurationManager.ConnectionStrings["connectionRRHHDatabase"].ConnectionString)) { SqlCommand command = new SqlCommand("usp_get_userAttributes_byCategorie", connection); command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.Add("@id_user", SqlDbType.Int); command.Parameters["@id_user"].Value = id_user; command.Parameters.Add("@id_categorie", SqlDbType.Int); command.Parameters["@id_categorie"].Value = id_categorie; command.Connection.Open(); SqlDataReader rdr = command.ExecuteReader(); while (rdr.Read()) { PersonalAttributeDTOmin personalAttribute = new PersonalAttributeDTOmin(); personalAttribute.attribute_id = rdr["id_attribute"].ToString(); personalAttribute.value = rdr["value"].ToString(); personalAttribute.type_id = rdr["type"].ToString(); personalAttribute.name = rdr["name"].ToString(); personaAttributeList.Add(personalAttribute); } }; return(personaAttributeList); }
public JsonResult _EditUserAttribute(Model.EditUserAttributeModel model) { if (ModelState.IsValid) { AttributeTypeDTO attributesType = categorieProvider.getAttributeType(model.type_id).Result; Regex r = new Regex(attributesType.reg_expr); if (r.Match(model.value).Success) { PersonalAttributeDTOmin userAttribute = new PersonalAttributeDTOmin(); userAttribute.attribute_id = model.attribute_id; userAttribute.value = model.value; userAttribute.user_id = model.user_id; userAttribute.userLog = Request.Cookies["user_id"].Value; if (userProvider.putUserAttribute(userAttribute).Result) { Response.StatusCode = 200; return(Json(model, JsonRequestBehavior.AllowGet)); //return new HttpStatusCodeResult(200, "hola"); } } Response.StatusCode = 400; Response.StatusDescription = "El campo valor es incorrecto"; return(Json(new { error = "El campo valor es incorrecto" }, JsonRequestBehavior.AllowGet)); } Response.StatusCode = 400; Response.StatusDescription = "Error, debe completar todos los campos"; return(Json(new { error = "Error, debe completar todos los campos" }, JsonRequestBehavior.AllowGet)); }
public IHttpActionResult updateUserAttribute(PersonalAttributeDTOmin personalAttributeDTO) { if (!UsersData.updateUserAttribute(personalAttributeDTO)) { return(BadRequest()); } return(Ok()); }
public async Task <bool> putUserAttribute(PersonalAttributeDTOmin personalAttributeDTO) { using (var client = new HttpClient()) { client.BaseAddress = new Uri(_BaseAddress); var userJson = new JavaScriptSerializer().Serialize(personalAttributeDTO); HttpContent contentPost = new StringContent(userJson, Encoding.UTF8, "application/json"); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", getToken()); HttpResponseMessage response = client.PutAsync("api/Users/attributes", contentPost).Result; if (response.IsSuccessStatusCode) { return(true); } return(false); } }