public async Task <ResponseMessage <TResult> > GetHighOrStandardParam <TResult>(string szUserToken) { userparameter param = new userparameter(); param.tool = "DEFAULT"; param.paramname = "HIGH_RESOLUTION"; param.system = "INGEST"; string uri = string.Format("http://{0}/CMApi/api/basic/config/getuserparam/", ApplicationContext.Current.CMServerUrl); ResponseMessage <TResult> result = new ResponseMessage <TResult>(); var dicHeader = new Dictionary <string, string>(); dicHeader.Add("sobeyhive-http-token", szUserToken); ResponseMessageN <etparam> reres = await _restClient.Post <ResponseMessageN <etparam> >(uri, param, dicHeader); if (reres.Code == "0") { result.Ext = _mapper.Map <TResult>(reres.ext); result.Code = ResponseCodeDefines.SuccessCode; } else { result.Ext = default(TResult); result.Code = ResponseCodeDefines.PartialFailure; } return(result); }
public async Task <IHttpActionResult> UpdateUserStatus([FromBody] userparameter userParameter) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var userFound = await UserManager.FindAsync(userParameter.userName, userParameter.userName); if (userParameter.estatus == 0 || userParameter.estatus == 2) { string userId = User.Identity.GetUserId(); var userRol = objInjUserRol.GetSingle(c => c.UserId == userId, includes: c => c.AspNetRoles); if (userRol == null) { userFound.Estatus = userParameter.estatus; IdentityResult result = await UserManager.UpdateAsync(userFound); if (!result.Succeeded) { return(BadRequest("No se pudo actualizar el status del usuario.")); } else { return(Ok(result)); } } else { return(BadRequest("No se puede desactivar el usuario porque tiene roles asignados.")); } } else { userFound.Estatus = userParameter.estatus; IdentityResult result = await UserManager.UpdateAsync(userFound); if (!result.Succeeded) { return(BadRequest("No se pudo actualizar el status del usuario.")); } else { return(Ok(result)); } } }