public static int GrabarCambioEstado(int IdUsuario, int OnOff) { try { if (IdUsuario > 0) { ApiServices objApi = new ApiServices(); string Request = "{}"; HttpResponseMessage response = objApi.CallService("usuarios/GetUsuariosById/" + IdUsuario, Request, ApiServices.TypeMethods.GET).Result; if (response.IsSuccessStatusCode) { string Respuesta = response.Content.ReadAsStringAsync().Result; Models.UsuarioViewModel objUsuario = Newtonsoft.Json.JsonConvert.DeserializeObject <Models.UsuarioViewModel>(Respuesta); if (objUsuario != null) { objUsuario.Estado = OnOff; string RequestPUT = Newtonsoft.Json.JsonConvert.SerializeObject(objUsuario); HttpResponseMessage responsePUT = objApi.CallService("usuarios/" + objUsuario.Id, RequestPUT, ApiServices.TypeMethods.PUT).Result; if (responsePUT.IsSuccessStatusCode) { return(1); } } //Models.Usuarios objUsuario = Newtonsoft.Json.JsonConvert.DeserializeObject<Models.Usuarios>(Respuesta); //if (objUsuario != null) //{ // objUsuario.Estado = OnOff; // response = null; // string Request2 = Newtonsoft.Json.JsonConvert.SerializeObject(objUsuario, new Newtonsoft.Json.JsonSerializerSettings() // { // PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.Objects, // Formatting = Newtonsoft.Json.Formatting.Indented // }); // response = objApi.CallService("usuarios/" + objUsuario.Id, Request2, ApiServices.TypeMethods.PUT).Result; // if (response.IsSuccessStatusCode) // { // return 1; // } //} return(0); } else { return(0); } } else { return(0); } } catch (Exception ex) { //Elmah.ErrorSignal.FromCurrentContext().Raise(ex); return(0); } }
// GET: Visualizar dados da conta public ActionResult Perfil(int id) { UsuarioDal uDal = new UsuarioDal(); Usuario usuario = uDal.FindById(id); PerfilDal pDal = new PerfilDal(); Perfil perfil = pDal.FindById(usuario.IdPerfil); UsuarioViewModel uView = new Models.UsuarioViewModel(); uView.Id = usuario.IdUsuario; uView.Nome = usuario.Nome; uView.Login = usuario.Login; uView.Perfil = perfil.Nome; return(View(uView)); }