public static VisitStateViewModel Create(VisitStateDto visitState, string returnUrl) { return(new VisitStateViewModel { VisitState = visitState, ReturnUrl = returnUrl }); }
public static VisitStateViewModel Delete(VisitStateDto visitState, string returnUrl) { return(new VisitStateViewModel { VisitState = visitState, Action = "Delete", ReadOnly = true, Theme = "danger", ReturnUrl = returnUrl }); }
public static VisitStateViewModel Edit(VisitStateDto visitState, string returnUrl) { return(new VisitStateViewModel { VisitState = visitState, Theme = "warning", Action = "Edit", ShowCreateNewAction = true, ReturnUrl = returnUrl }); }
public static VisitStateViewModel Details(VisitStateDto visitState, string returnUrl) { return(new VisitStateViewModel { VisitState = visitState, Action = "Details", ReadOnly = true, Theme = "info", ShowAction = false, ReturnUrl = returnUrl }); }
public async Task DeleteVisitState(VisitStateDto visitState) { using (var httpClient = new HttpClient()) { using (var response = await httpClient.DeleteAsync(uri.AbsoluteUri + visitState.Id)) { if (!response.IsSuccessStatusCode) { //string apiResponse = await response.Content.ReadAsStringAsync(); throw new Exception(); } } } }
public async Task UpdateVisitState(VisitStateDto visitState) { using (var httpClient = new HttpClient()) { StringContent content = new StringContent(JsonConvert.SerializeObject(visitState), Encoding.UTF8, "application/json"); using (var response = await httpClient.PutAsync(uri.AbsoluteUri + visitState.Id, content)) { if (!response.IsSuccessStatusCode) { throw new Exception(); } } } }
public async Task <VisitStateDto> GetVisitState(int id) { VisitStateDto visitState = new VisitStateDto(); using (var httpClient = new HttpClient()) { using (var response = await httpClient.GetAsync(uri.AbsoluteUri + id)) { if (response.IsSuccessStatusCode) { string apiResponse = await response.Content.ReadAsStringAsync(); visitState = JsonConvert.DeserializeObject <VisitStateResponseDto>(apiResponse).VisitState; } } } return(visitState); }
public async Task <VisitStateDto> AddVisitState(VisitStateDto visitState) { VisitStateDto receivedVisitState = new VisitStateDto(); using (var httpClient = new HttpClient()) { StringContent content = new StringContent(JsonConvert.SerializeObject(visitState), Encoding.UTF8, "application/json"); using (var response = await httpClient.PostAsync(uri.AbsoluteUri, content)) { if (!response.IsSuccessStatusCode) { throw new Exception(); } string apiResponse = await response.Content.ReadAsStringAsync(); receivedVisitState = JsonConvert.DeserializeObject <VisitStateResponseDto>(apiResponse).VisitState; } } return(receivedVisitState); }