public TaskResult<bool> JoinGroup(JoinDetail jdetail) { TaskResult<bool> result = null; try { _groupRepository.JoinGroup(jdetail); _groupRepository.SaveChanges(); result = new TaskResult<bool> { Data = true, state = StatusState.DoneState }; } catch (Exception e) { Logger.Instance.LogException(e); result = new TaskResult<bool> { Data = false, state = StatusState.CancelState }; } return result; }
public TaskResult<bool> JoinGroup(JoinDetail detail) { TaskResult<bool> result; HttpClient client = GetHTTPClient(); var content = new ObjectContent(typeof(JoinDetail), detail, new JsonMediaTypeFormatter()); HttpResponseMessage response = client.PostAsync("api/Group/Join", content).Result; if (response.IsSuccessStatusCode) { result = response.Content.ReadAsAsync<TaskResult<bool>>().Result; } else { result = new TaskResult<bool> { state = StatusState.CancelState, Data = false }; } return result; }