/// <summary> /// 更新启用状态 /// </summary> /// <param name="request"></param> /// <returns></returns> public UpdateStatusResponse UpdateStatus(UpdateStatusRequest request) { var response = new UpdateStatusResponse(); try { var entity = _appIdAuthTokenRepository.Find <AppIdAuthPo>(e => e.IsValid == 1 && e.Id == request.Id); if (entity == null) { throw new Exception("修改应用授权不存在"); } entity.Status = request.Status; EntityLogger.UpdateEntity(entity); _appIdAuthTokenRepository.UpdateColumns(entity, (e) => new { e.Status, e.UpdateTime, e.UpdateUserId }); var key = entity.AppId.AddCachePrefix("AppIdAuth"); CacheManager.RedisDefault.Del(key); } catch (Exception ex) { response.IsSuccess = false; response.MessageCode = "-1"; response.MessageText = ex.Message; LogManager.LogicLogger.ErrorFormat("更新启用状态出错:{0}", new { request, err = ex.ToString() }.ToJson()); } return(response); }
private async void Complete_workout_clicked(object sender, EventArgs e) { try { Common common = new Common(); common.UserID = 1; UpdateStatusResponse _response = new UpdateStatusResponse(); //_response.Response = new Responses(); string s = JsonConvert.SerializeObject(common); HttpResponseMessage response = null; string uri = "http://noti.fit:130/api/Workout/StatusUpdateCompleted?WorkoutId=" + _objWorkoutlist.WorkoutId; using (var stringContent = new StringContent(s, System.Text.Encoding.UTF8, "application/json")) { string token = Settings.TokenCode; HttpClient client = new HttpClient(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); response = await client.PostAsync(uri, stringContent); if (response.IsSuccessStatusCode) { var SucessResponse = await response.Content.ReadAsStringAsync(); _response = JsonConvert.DeserializeObject <UpdateStatusResponse>(SucessResponse); DependencyService.Get <IToast>().Show("Status Completed"); } else { var ErrorResponse = await response.Content.ReadAsStringAsync(); _response = JsonConvert.DeserializeObject <UpdateStatusResponse>(ErrorResponse); DependencyService.Get <IToast>().Show("Token error"); } } } catch (Exception ex) { } }