public static RegisterControlViewModel Create(RegisterControlDto registerControl, string returnUrl) { return(new RegisterControlViewModel { RegisterControl = registerControl, ReturnUrl = returnUrl }); }
public static RegisterControlViewModel Delete(RegisterControlDto registerControl, string returnUrl) { return(new RegisterControlViewModel { RegisterControl = registerControl, Action = "Delete", ReadOnly = true, Theme = "danger", ReturnUrl = returnUrl }); }
public static RegisterControlViewModel Edit(RegisterControlDto registerControl, string returnUrl) { return(new RegisterControlViewModel { RegisterControl = registerControl, Theme = "warning", Action = "Edit", ShowCreateNewAction = true, ReturnUrl = returnUrl }); }
public static RegisterControlViewModel Details(RegisterControlDto registerControl, string returnUrl) { return(new RegisterControlViewModel { RegisterControl = registerControl, Action = "Details", ReadOnly = true, Theme = "info", ShowAction = false, ReturnUrl = returnUrl }); }
public async Task DeleteRegisterControl(RegisterControlDto registerControl) { using (var httpClient = new HttpClient()) { using (var response = await httpClient.DeleteAsync(uri.AbsoluteUri + registerControl.Id)) { if (!response.IsSuccessStatusCode) { //string apiResponse = await response.Content.ReadAsStringAsync(); throw new Exception(); } } } }
public async Task UpdateRegisterControl(RegisterControlDto registerControl) { using (var httpClient = new HttpClient()) { StringContent content = new StringContent(JsonConvert.SerializeObject(registerControl), Encoding.UTF8, "application/json"); using (var response = await httpClient.PutAsync(uri.AbsoluteUri + registerControl.Id, content)) { if (!response.IsSuccessStatusCode) { throw new Exception(); } } } }
public async Task <RegisterControlDto> GetRegisterControl(int id) { RegisterControlDto registerControl = new RegisterControlDto(); using (var httpClient = new HttpClient()) { using (var response = await httpClient.GetAsync(uri.AbsoluteUri + id)) { if (response.IsSuccessStatusCode) { string apiResponse = await response.Content.ReadAsStringAsync(); registerControl = JsonConvert.DeserializeObject <RegisterControlResponseDto>(apiResponse).RegisterControl; } } } return(registerControl); }
public async Task <RegisterControlDto> AddRegisterControl(RegisterControlDto registerControl) { RegisterControlDto receivedRegisterControl = new RegisterControlDto(); using (var httpClient = new HttpClient()) { StringContent content = new StringContent(JsonConvert.SerializeObject(registerControl), 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(); receivedRegisterControl = JsonConvert.DeserializeObject <RegisterControlResponseDto>(apiResponse).RegisterControl; } } return(receivedRegisterControl); }