/// <summary> /// Deletes the asynchronous. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="requestUri">The request URI.</param> /// <param name="value">The value.</param> /// <returns></returns> public async Task <T> DeleteAsync <T>(string requestUri, object value) { T result = default(T); try { HttpResponseMessage response = await HttpRequestFactory.Delete(requestUri, value, this.auth_token, this.dbName); if (response.IsSuccessStatusCode) { return(await response.Content.ReadAsAsync <T>()); } else { var error = response.Content.ReadAsStringAsync().Result; ViewBag.Message = error; TempData["Message"] = error; Utilities.LogAppInformation(this.logger, error); return(result); } } catch (Exception ex) { ModelState.AddModelError("CommonController", ex.Message); ViewBag.Message = ex.Message; TempData["Message"] = ex.Message; Utilities.LogAppError(this.logger, ex); return(result); } }
private static async Task Delete() { var requestUri = $"{baseUri}/4"; var response = await HttpRequestFactory.Delete(requestUri); Console.WriteLine($"Status: {response.StatusCode}"); }
public ActionResult DeleteUniverso(int id) { string token = Microsoft.AspNetCore.Authentication.AuthenticationHttpContextExtensions.GetTokenAsync(HttpContext, "access_token").Result; var response = HttpRequestFactory.Delete(_configuration["Endpoints:Universos"] + "/" + id, token).Result; _logger.LogInformation(string.Format("DeleteUniverso: StatusCode:{0} , RequestMessage:{1} ", response.StatusCode, response.RequestMessage)); return(convertMessage(response, response.ContentAsJson())); }
public async Task <IActionResult> OnPostAsync() { var baseUri = Startup.Configuration["API_URL"]; var requestUri = $"{baseUri}/{this.Id}"; var response = await HttpRequestFactory.Delete(requestUri); return(RedirectToPage("./Index")); }
private async Task <String> DeleteAKSAsync(string servername, string token) { var subscriptionID = "b9049f27-f15e-41ae-8853-8bc37dce9630"; var resourceGroup = "desafio2"; var requestUri = String.Format("https://management.azure.com/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.ContainerService/managedClusters/{2}?api-version=2018-03-31", subscriptionID, resourceGroup, servername); var response = await HttpRequestFactory.Delete(requestUri, token); return(response.StatusCode.ToString()); }
public async Task <bool> Delete(int[] ids) { var response = await HttpRequestFactory.Delete(URI, ids); if ((int)response.StatusCode == 204) { return(true); } else { return(false); } }
public async Task <ResponseMessage> ResponseMessageFromDeleteUrl(string requestUri) { try { var response = await HttpRequestFactory.Delete(requestUri, this._httpContextAccessor.HttpContext.Session.GetString(SessionTypes.TOKEN), this._roleCodeController); response.EnsureSuccessStatusCode(); return(JsonConvert.DeserializeObject <ResponseMessage>(await response.Content.ReadAsStringAsync())); } catch (Exception e) { this._errorHandler.WriteToFile(e); } return(new ResponseMessage("-1", this._requestFailMessage)); }
public async Task <IActionResult> Delete(int id) { var response = await HttpRequestFactory.Delete(Constants.BaseApiUrl + "CategoryBookingStatus?id=" + id); var outmodel = response.ContentAsType <SingleModelResponse <CategoryBookingStatus> >(); if (outmodel.DidError || !response.IsSuccessStatusCode) { return(Json(new { error = outmodel.ErrorMessage ?? response.ReasonPhrase })); } return(RedirectToAction("Index")); }
public async Task <IActionResult> VerifyDelete(int mappingId) { string url = $"{CoreApiUrl}ResponseTeamMappings/Delete?mappingId={mappingId}"; var accessToken = await HttpContext.GetTokenAsync("access_token"); var response = await HttpRequestFactory.Delete(accessToken, url); if (response.StatusCode == HttpStatusCode.OK) { AppContextHelper.SetToastMessage("Response team member mapping has been successfully deleted", MessageType.Success, 1, Response); return(RedirectToAction(nameof(Index), new { teamMemberId = _teamMemberId, teamMemberName = _teamMemberName })); } else { AppContextHelper.SetToastMessage("Failed to delete response team member mapping", MessageType.Danger, 1, Response); ModelState.AddModelError("", HttpResponseHandler.Process(response)); } return(RedirectToAction(nameof(Delete), new { mappingId })); }
public async Task <IActionResult> Delete(int id) { var response = await HttpRequestFactory.Delete(Constants.BaseApiUrl + "PartnerContact?id=" + id); if (response.IsSuccessStatusCode) { return(Json(new { title = "Xóa thành công!", message = "Dữ liệu đã được xóa." })); } if (response.StatusCode == HttpStatusCode.NotFound) { return(NotFound()); } return(BadRequest()); }
public async Task <IActionResult> VerifyDelete(string countryCode) { string url = $"{CoreApiUrl}Countries/Delete?countryCode={countryCode}"; var Country = new CountryDTO(); var accessToken = await HttpContext.GetTokenAsync("access_token"); var response = await HttpRequestFactory.Delete(accessToken, url); if (response.StatusCode == HttpStatusCode.OK) { AppContextHelper.SetToastMessage("Country has been successfully deleted", MessageType.Success, 1, Response); return(RedirectToAction(nameof(Index))); } else { AppContextHelper.SetToastMessage("Failed to delete country", MessageType.Danger, 1, Response); ModelState.AddModelError("", HttpResponseHandler.Process(response)); } return(View(await GetCountry(countryCode))); }
public async Task <IActionResult> VerifyDelete(int notificationId) { string url = $"{NotificationsApiUrl}BulkNotifications/Delete?notificationId={notificationId}"; var BulkNotification = new BulkNotificationDTO(); var accessToken = await HttpContext.GetTokenAsync("access_token"); var response = await HttpRequestFactory.Delete(accessToken, url); if (response.StatusCode == HttpStatusCode.OK) { AppContextHelper.SetToastMessage("Bulk notification has been successfully deleted", MessageType.Success, 1, Response); return(RedirectToAction(nameof(Index))); } else { AppContextHelper.SetToastMessage("Failed to delete bulk notification", MessageType.Danger, 1, Response); ModelState.AddModelError("", HttpResponseHandler.Process(response)); } return(View(await GetBulkNotification(notificationId))); }
public async Task <IActionResult> VerifyDelete(string resourceId) { string url = $"{ResourcesApiUrl}Delete?resourceId={resourceId}"; var Resource = new ResourceDTO(); var accessToken = await HttpContext.GetTokenAsync("access_token"); var response = await HttpRequestFactory.Delete(accessToken, url); if (response.StatusCode == HttpStatusCode.OK) { AppContextHelper.SetToastMessage("Resource has been successfully deleted", MessageType.Success, 1, Response); return(RedirectToAction(nameof(Index))); } else { AppContextHelper.SetToastMessage("Failed to delete resource", MessageType.Danger, 1, Response); ModelState.AddModelError("", HttpResponseHandler.Process(response)); } return(View(await GetResource(resourceId))); }
public async Task <IActionResult> VerifyDelete(int symptomId) { string url = $"{PatientsApiUrl}Symptoms/Delete?symptomId={symptomId}"; var PatientSymptom = new PatientSymptomDTO(); var accessToken = await HttpContext.GetTokenAsync("access_token"); var response = await HttpRequestFactory.Delete(accessToken, url); if (response.StatusCode == HttpStatusCode.OK) { AppContextHelper.SetToastMessage("Patient symptom has been successfully deleted", MessageType.Success, 1, Response); return(RedirectToAction(nameof(Index))); } else { AppContextHelper.SetToastMessage("Failed to delete patient symptom", MessageType.Danger, 1, Response); ModelState.AddModelError("", HttpResponseHandler.Process(response)); } return(View(await GetPatientSymptom(symptomId))); }
public async Task <IActionResult> VerifyDelete(int ruleId) { string url = $"{NotificationsApiUrl}ScheduledNotificationEscalationRules/Delete?ruleId={ruleId}"; var ScheduledNotificationEscalationRule = new ScheduledNotificationEscalationRuleDTO(); var accessToken = await HttpContext.GetTokenAsync("access_token"); var response = await HttpRequestFactory.Delete(accessToken, url); if (response.StatusCode == HttpStatusCode.OK) { AppContextHelper.SetToastMessage("Scheduled notification escalation rule has been successfully deleted", MessageType.Success, 1, Response); return(RedirectToAction(nameof(Index))); } else { AppContextHelper.SetToastMessage("Failed to delete scheduled notification escalation rule", MessageType.Danger, 1, Response); ModelState.AddModelError("", HttpResponseHandler.Process(response)); } return(View(await GetScheduledNotificationEscalationRule(ruleId))); }
public async Task <IActionResult> VerifyDelete(int facilityTypeId) { string url = $"{CoreApiUrl}FacilityTypes/Delete?facilityTypeId={facilityTypeId}"; var FacilityType = new FacilityTypeDTO(); var accessToken = await HttpContext.GetTokenAsync("access_token"); var response = await HttpRequestFactory.Delete(accessToken, url); if (response.StatusCode == HttpStatusCode.OK) { AppContextHelper.SetToastMessage("Facility type has been successfully deleted", MessageType.Success, 1, Response); return(RedirectToAction(nameof(Index))); } else { AppContextHelper.SetToastMessage("Failed to delete identification Type", MessageType.Danger, 1, Response); ModelState.AddModelError("", HttpResponseHandler.Process(response)); } return(View(await GetFacilityType(facilityTypeId))); }
public async Task <IActionResult> VerifyDelete(int workerId) { string url = $"{CoreApiUrl}HealthCareWorkers/Delete?workerId={workerId}"; var accessToken = await HttpContext.GetTokenAsync("access_token"); var response = await HttpRequestFactory.Delete(accessToken, url); if (response.StatusCode == HttpStatusCode.OK) { AppContextHelper.SetToastMessage("Health care worker has been successfully deleted", MessageType.Success, 1, Response); return(RedirectToAction(nameof(Index))); } else { AppContextHelper.SetToastMessage("Failed to delete health care worker", MessageType.Danger, 1, Response); ModelState.AddModelError("", HttpResponseHandler.Process(response)); } var HealthCareWorker = await GetHealthCareWorker(workerId); return(View(HealthCareWorker)); }
/// <summary> /// Delete a mapping Deletes a mapping. /// </summary> /// <param name="id"></param> /// <returns></returns> public void DataPointMappingsIdDelete(string id) { // verify the required parameter 'id' is set if (id == null) { throw new ApiException(400, "Missing required parameter 'id' when calling DataPointMappingsIdDelete"); } const string endpoint = "/dataPointMappings/{id}"; string requestUri = $"{this.BasePath}{endpoint}"; var response = HttpRequestFactory.Delete(requestUri).Result; if (((int)response.StatusCode) >= 400) { throw new ApiException((int)response.StatusCode, "Error calling DataPointMappingsIdDelete: " + response.Content, response.Content); } else if (((int)response.StatusCode) == 0) { throw new ApiException((int)response.StatusCode, "Error calling DataPointMappingsIdDelete: " + response.ReasonPhrase, response.ReasonPhrase); } return; }
public async Task <ActionResult> Delete(int id) { try { if (ModelState.IsValid) { var requestUri = $"{WebApiBaseUrl}{TenantDeleteEndPoint}/{id}"; HttpResponseMessage httpResponseMessage = await HttpRequestFactory.Delete(requestUri); var response = httpResponseMessage.ContentAsType <ApiResponse>(); if (response.StatusCode == HttpStatusCode.OK) { return(RedirectToAction("Index", "Tenant")); } } return(null); } catch (Exception ex) { throw ex; } }
public async Task <TResponse> Execute <TResponse>(ApiRequestBase <TResponse> request) where TResponse : ApiResponseBase { if (request.HttpMethod == HttpMethod.Post) { return(await HttpRequestFactory.Post(request.Url, request.GetPostContent(), request.Header, true).ContentToType <TResponse>()); } if (request.HttpMethod == HttpMethod.Put) { return(await HttpRequestFactory.Put(request.Url, request.GetPostContent(), request.Header).ContentToType <TResponse>()); } if (request.HttpMethod == HttpMethod.Get) { return(await HttpRequestFactory.Get(request.Url, request.Header, true).ContentToType <TResponse>()); } if (request.HttpMethod == HttpMethod.Delete) { return(await HttpRequestFactory.Delete(request.Url, request.Header).ContentToType <TResponse>()); } throw new NotSupportedException("不支持的方法"); }
public async Task <IActionResult> Delete(int id) { var response = await HttpRequestFactory.Delete(Constants.BaseApiUrl + "Partner?id=" + id); var outmodel = response.ContentAsType <SingleModelResponse <PartnerResource> >(); if (outmodel.DidError || !response.IsSuccessStatusCode) { return(Json(new { status = false, title = "Lỗi", message = "Đã xảy ra lỗi. Vui lòng liên hệ admin!", error = outmodel.ErrorMessage ?? response.ReasonPhrase })); } return(Json(new { status = true, title = "Xóa thành công", message = "Đối tác " + outmodel.Model.PartnerName + " đã được xóa." })); }
public async Task TearDownCreatedMenu() { response = await HttpRequestFactory.Delete(menuApiUrl, $"{menuPath}{menuId}"); Console.WriteLine($"Successfully deleted menuId ={menuId}"); }
public async Task WhenIDeleteTheCategory() { lastResponse = await HttpRequestFactory.Delete(baseUrl, $"{MenuSteps.menuPath}{existingMenuId}{categoryPath}{existingCategoryId}"); }
public async Task DeleteWorks() { await HttpRequestFactory.Delete("https://jsonplaceholder.typicode.com/posts/1"); }
public async Task WhenIDeleteAMenu() { lastResponse = await HttpRequestFactory.Delete(baseUrl, $"{menuPath}{existingMenuId}"); }
protected static async Task <HttpResponseMessage> DeleteRequestToApi(string requestUri) { return(await HttpRequestFactory.Delete(requestUri)); }