コード例 #1
0
        public void DeleteAsync_PerformsCorrectRequest()
        {
            HttpRequestMessage actualRequest = null;

            _innerHandler.Protected()
            .Setup <Task <HttpResponseMessage> >("SendAsync", ItExpr.IsAny <HttpRequestMessage>(), ItExpr.IsAny <CancellationToken>())
            .Returns(Task.FromResult(new HttpResponseMessage()))
            .Callback <HttpRequestMessage, CancellationToken>((request, _) => actualRequest = request);

            _testObject.DeleteAsync("path/id", CancellationToken.None).Wait();

            Assert.NotNull(actualRequest);
            Assert.AreEqual(HttpMethod.Delete, actualRequest.Method);
            Assert.AreEqual(BaseAddress + "/path/id", actualRequest.RequestUri.ToString());
        }
コード例 #2
0
 public ActionResult DeleteScheduleConfirmed(int id)
 {
     using (HttpClientWrapper httpClient = new HttpClientWrapper(Session))
     {
         var responseMessage = httpClient.DeleteAsync("api/ScheduleAPI/" + id.ToString()).Result;
         responseMessage.EnsureSuccessStatusCode();
     }
     return(RedirectToAction("IndexSchedule"));
 }
コード例 #3
0
 public ActionResult RecurringShiftDeleteConfirmed(Guid BusinessLocationId, Guid id)
 {
     using (HttpClientWrapper httpClient = new HttpClientWrapper(Session))
     {
         var responseMessage = httpClient.DeleteAsync("api/ShiftTemplateAPI/" + id.ToString()).Result;
         responseMessage.EnsureSuccessStatusCode();
     }
     return(RedirectToAction("RecurringShiftIndex", new { businesslocationid = BusinessLocationId }));
 }
コード例 #4
0
 public ActionResult RoleDeleteConfirmed(Guid employeeid, Guid id)
 {
     using (HttpClientWrapper httpClient = new HttpClientWrapper(Session))
     {
         var responseMessage = httpClient.DeleteAsync("api/EmployeeAPI/Employee/" + employeeid.ToString() + "/Role/" + id.ToString()).Result;
         responseMessage.EnsureSuccessStatusCode();
     }
     return(RedirectToAction("RoleIndex", new { employeeid = employeeid }));
 }
コード例 #5
0
        public async Task <bool> DeleteAsync(string requestUri)
        {
            using (HttpClientWrapper client = await this.GetHttpClient())
            {
                this.LogRequest(requestUri);
                HttpResponseMessage response = await client.DeleteAsync(requestUri);

                return(response.StatusCode == HttpStatusCode.NoContent);
            }
        }
コード例 #6
0
 private async Task DeleteAsync(string endpoint)
 {
     try
     {
         using (HttpClientWrapper client = new HttpClientWrapper(MixItUpAPIEndpoint))
         {
             HttpResponseMessage response = await client.DeleteAsync(endpoint);
         }
     }
     catch (Exception) { }
 }
コード例 #7
0
        private async Task DeleteAsync(string endpoint)
        {
            try
            {
                using (HttpClientWrapper client = new HttpClientWrapper(MixItUpAPIEndpoint))
                {
                    HttpResponseMessage response = await client.DeleteAsync(endpoint);

                    await this.ProcessResponseIfError(response);
                }
            }
            catch (Exception ex) { Logger.Log(ex); }
        }
コード例 #8
0
        public ActionResult RoleDeleteConfirmed(Guid businessid, Guid id)
        {
            using (HttpClientWrapper httpClient = new HttpClientWrapper(Session))
            {
                var responseMessage = httpClient.DeleteAsync("api/BusinessAPI/Business/" + businessid.ToString() + "/Role/" + id.ToString()).Result;
                responseMessage.EnsureSuccessStatusCode();
            }

            //Invalidate dependant cache item
            CacheManager.Instance.Remove(CacheManager.CACHE_KEY_BUSINESS + businessid.ToString());

            return(RedirectToAction("RoleIndex", new { businessid = businessid }));
        }
コード例 #9
0
        public async Task DeleteById(string path, string id, string token = null)
        {
            _loggerWrapper.LogInformation("path: " + path + " " + "id: " + id, this.GetType().Name, nameof(DeleteById) + "()", null);

            try
            {
                await HttpClientWrapper.DeleteAsync(path, id, token);
            }
            catch (HttwrapException httwrapException)
            {
                _loggerWrapper.LogError("Failed to find item with ID: " + id, this.GetType().Name, nameof(DeleteById) + "()", null);
                _loggerWrapper.LogError(httwrapException.Message, this.GetType().Name, nameof(DeleteById) + "()", null);
                _loggerWrapper.LogError(httwrapException.InnerException != null ? httwrapException.InnerException.Message : null, this.GetType().Name, nameof(DeleteById) + "()", null);

                throw new HttwrapException("Failed to find item with ID: " + id, httwrapException);
            }
        }
コード例 #10
0
        public ActionResult DeleteConfirmed(Guid businesslocationId, Guid id)
        {
            //Get roles for business
            BusinessController bc = new BusinessController();
            var busLoc            = bc.GetBusinessLocation(businesslocationId, this.Session);


            using (HttpClientWrapper httpClient = new HttpClientWrapper(Session))
            {
                var responseMessage = httpClient.DeleteAsync("api/ShiftBlockAPI/" + id.ToString()).Result;
                responseMessage.EnsureSuccessStatusCode();

                CacheManager.Instance.Remove(CacheManager.CACHE_KEY_BUSINESS_LOCATION + busLoc.Id.ToString()); //Remove the stale business item from the cache
                CacheManager.Instance.Remove(CacheManager.CACHE_KEY_BUSINESS + busLoc.BusinessId.ToString());  //Remove the stale business item from the cache
            }
            return(RedirectToAction("Index", new { businesslocationid = businesslocationId }));
        }
コード例 #11
0
        /// <summary>
        /// Performs a DELETE REST request using the provided request URI.
        /// </summary>
        /// <param name="requestUri">The request URI to use</param>
        /// <returns>Whether the deletion was successful</returns>
        public async Task <bool> DeleteAsync(string requestUri, HttpContent content = null)
        {
            using (HttpClientWrapper client = await this.GetHttpClient())
            {
                this.LogRequest(requestUri);
                if (content != null)
                {
                    HttpMethod         method  = new HttpMethod("DELETE");
                    HttpRequestMessage request = new HttpRequestMessage(method, requestUri)
                    {
                        Content = content
                    };
                    HttpResponseMessage response = await client.SendAsync(request);

                    return(response.StatusCode == HttpStatusCode.NoContent);
                }
                else
                {
                    HttpResponseMessage response = await client.DeleteAsync(requestUri);

                    return(response.StatusCode == HttpStatusCode.NoContent);
                }
            }
        }
 public async Task DeleteAsync(int id, IPrincipal principal)
 {
     await _httpClient.DeleteAsync($"governor/{id}", null, principal);
 }
コード例 #13
0
ファイル: EmployeesController.cs プロジェクト: oliko20/HR
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            await _clientWrapper.DeleteAsync($"api/Employees/{id}");

            return(RedirectToAction("Index"));
        }