public DeleteCustomerResponse DeleteCustomer(DeleteCustomerRequest request) { AdministrationServiceDAO adminDAO = new AdministrationServiceDAO(); bool result = adminDAO.DeleteCustomer(request.customer); return(new DeleteCustomerResponse(result)); }
public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "delete", Route = "customers/{id}")] HttpRequest req, string id, [Inject] ICustomerService customerService, ILogger logger ) { logger.LogInformation($"Calling {nameof(DeleteCustomerFunction)}"); if (!int.TryParse(id, out var customerId)) { logger.LogError($"Error: Invalid request, id must be integer: {id}"); return(new BadRequestObjectResult($"Invalid request, id must be integer: {id}")); } var deleteCustomerRequest = new DeleteCustomerRequest(customerId); var isValid = deleteCustomerRequest.Validate(); if (!isValid) { logger.LogError("Error: Invalid request"); return(new BadRequestObjectResult("Invalid request")); } var operationResult = await customerService.DeleteCustomerAsync(deleteCustomerRequest).ConfigureAwait(false); if (operationResult.Status) { return(new OkObjectResult("Customer deleted successfully")); } return(new BadRequestObjectResult(operationResult.Message)); }
private static async Task DeleteCustomer(CustomerServiceDefinition.CustomerServiceDefinitionClient customerClient) { var input = new DeleteCustomerRequest { Id = 3 }; var reply = await customerClient.DeleteCustomerAsync(input); }
public async Task TestSuccess() { // Arrange Mock <IDataRepository <Customer, Guid> > mockRepository = new Mock <IDataRepository <Customer, Guid> >(); Guid id = new Guid("b7c2acaa-ad72-47b3-b858-26357cf14fbb"); Customer customer = new Customer() { Id = id }; mockRepository.Setup(m => m.FindAsync(id, default)).Returns(new ValueTask <Customer>(customer)); DeleteCustomerRequest request = new DeleteCustomerRequest() { Id = id }; DeleteCustomerCommand sut = new DeleteCustomerCommand(MockHelpers.GetLogger <DeleteCustomerCommand>(), mockRepository.Object); // Act DeleteCustomerResponse result = await sut.Handle(request, default); // Assert Assert.IsNotNull(result); mockRepository.VerifyAll(); mockRepository.Verify(m => m.FindAsync(id, default), Times.Once); mockRepository.Verify(m => m.Delete(customer), Times.Once); }
public DeleteCustomerResponse DeleteCustomer(DeleteCustomerRequest deleteCustomerRequest) { try { Customer customer = _customerRepository.FindBy(deleteCustomerRequest.Id); if (customer != null) { _customerRepository.Delete(customer); _unitOfWork.Commit(); return(new DeleteCustomerResponse()); } else { return(new DeleteCustomerResponse() { Exception = GetStandardCustomerNotFoundException() }); } } catch (Exception ex) { return(new DeleteCustomerResponse() { Exception = ex }); } }
public async void Run_DeleteCustomerTest() { ShowTestOnTerminal("DeleteCustomer"); UpdateCustomerRequest setupRequest = new UpdateCustomerRequest { Customer = new Customer { FirstName = "Test", LastName = "Customer", CompanyName = "Test Company", EmailAddress = "*****@*****.**", SmsNumber = "(123) 123-1234", }, }; output.WriteLine("Setup request: {0}", setupRequest); CustomerResponse setupResponse = await blockchyp.UpdateCustomerAsync(setupRequest); output.WriteLine("Setup Response: {0}", setupResponse); DeleteCustomerRequest request = new DeleteCustomerRequest { CustomerId = setupResponse.Customer.Id, }; output.WriteLine("Request: {0}", request); DeleteCustomerResponse response = await blockchyp.DeleteCustomerAsync(request); output.WriteLine("Response: {0}", response); Assert.True(response.Success, "response.Success"); }
public async Task With_Valid_Request_Existing_Customer_Can_Be_Deleted() { // // Arrange // var httpResponse = await _client.PostAsJsonAsync(BaseUrl, new CreateCustomerRequest { FirstName = "john", LastName = "snow", DateOfBirth = new DateTime(2000, 1, 1) }); var createdCustomerDto = JsonConvert.DeserializeObject <DisplayCustomerDto>(await httpResponse.Content.ReadAsStringAsync()); var deleteRequest = new DeleteCustomerRequest { CustomerId = createdCustomerDto.Id }; // // Act // httpResponse = await _client.SendAsync(new HttpRequestMessage(HttpMethod.Delete, BaseUrl) { Content = new StringContent(JsonConvert.SerializeObject(deleteRequest), Encoding.UTF8, "application/json") }); // // Assert // httpResponse.EnsureSuccessStatusCode(); }
public async Task <ActionResult> DeleteCustomerAsync(int id) { var request = new DeleteCustomerRequest { Id = id }; var response = await Service.DeleteCustomerAsync(request); return(NoContent()); }
public DeleteCustomerResponse DeleteCustomer(DeleteCustomerRequest request) { DeleteCustomerResponse response = new DeleteCustomerResponse(); CustomerBusinessComponent bc = DependencyInjectionHelper.GetCustomerBusinessComponent(); bc.DeleteCustomer(request.CustomerId); return(response); }
public async Task <ActionResult> Delete([FromBody] DeleteCustomerRequest request) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var res = await _customerService.DeleteAsync(request); return(Ok(res)); }
public async Task <string> DeleteAsync(DeleteCustomerRequest request) { var customer = await _dbContext.Customers.FirstOrDefaultAsync(p => p.Id == new Guid(request.Id)); customer.IsDelete = true; await _dbContext.SaveChangesAsync(); return(customer.Id.ToString()); }
public async Task DeleteCustomer_NotExistRequest_ThrowsNotFoundRequestException() { var id = Guid.NewGuid(); var deleteRequest = new DeleteCustomerRequest { Id = id }; await Assert.ThrowsAsync <NotFoundRequestException>(() => Fixture.Customers.DeleteCustomerAsync(deleteRequest)); }
public async Task DeleteCustomer_ValidRequest_ReturnsResponse() { var customerRecord = _customerRecords[0]; var id = customerRecord.Id; var deleteRequest = new DeleteCustomerRequest { Id = id }; var deleteResponse = await Fixture.Customers.DeleteCustomerAsync(deleteRequest); }
public JsonResult DeleteCustomer([FromBody] DeleteCustomerRequest request) { BaseResponse baseResponse = new BaseResponse(); Bayi.DataAccess.Customer byId = this._customerService.GetById(request.CustomerId); byId.IsActive = false; this._customerService.Update(byId); baseResponse.Number = 1; baseResponse.Message = "Kullanıcı başarıyla silinmiştir.."; return(this.Json((object)baseResponse)); }
public async Task DeleteCustomer_NotExist_NotFound() { var id = Guid.NewGuid(); var deleteRequest = new DeleteCustomerRequest { Id = id }; var deleteResponse = await Fixture.Api.Customers.DeleteCustomerAsync(deleteRequest); Assert.Equal(HttpStatusCode.NotFound, deleteResponse.StatusCode); }
public async Task <DeleteCustomerResponse> DeleteCustomerAsync( long customerId, byte[] timeStamp) { var request = new DeleteCustomerRequest { CustomerId = customerId, TimeStamp = timeStamp }; return(await CustomerManagementService.CallAsync((s, r) => s.DeleteCustomerAsync(r), request)); }
public async Task <IActionResult> Delete([FromBody] DeleteCustomerRequest request) { var operationResult = await _customerService.DeleteCustomerAsync(request.ToServiceRequest()).ConfigureAwait(false); if (!operationResult.Status) { _logger.LogError($"Error: Cannot delete customer"); } var actionResult = _deleteCustomerResponsePresenter.Handle(operationResult); return(actionResult); }
public async Task DeleteCustomer_Valid_OK() { var customerRecord = _customerRecords[0]; var id = customerRecord.Id; var deleteRequest = new DeleteCustomerRequest { Id = id }; var deleteResponse = await Fixture.Api.Customers.DeleteCustomerAsync(deleteRequest); Assert.Equal(HttpStatusCode.NoContent, deleteResponse.StatusCode); }
/// <summary>Snippet for DeleteCustomer</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void DeleteCustomerRequestObject() { // Create client CloudChannelServiceClient cloudChannelServiceClient = CloudChannelServiceClient.Create(); // Initialize request argument(s) DeleteCustomerRequest request = new DeleteCustomerRequest { CustomerName = CustomerName.FromAccountCustomer("[ACCOUNT]", "[CUSTOMER]"), }; // Make the request cloudChannelServiceClient.DeleteCustomer(request); }
/// <summary> /// Deletes the customer. --Robin /// </summary> /// <param name="id">The id.</param> /// <returns></returns> public bool DeleteCustomer(int id) { DeleteCustomerRequest request = new DeleteCustomerRequest(); request.Id = id; DeleteCustomerResponse response = MyChannelFactory.CreateChannel().DeleteCustomer(request); if (response.IsFailed) { throw new Exception("We have a error!" + response.Message); } return(response.IsFailed); }
private void btnDelete_Click(object sender, EventArgs e) { if (dgvList.CurrentRow == null) { SOAFramework.Client.Controls.MessageBox.Show(this, "请选择一条数据"); return; } if (SOAFramework.Client.Controls.MessageBox.Show(this, "确认删除选中的数据吗?", "删除", MessageBoxButtons.YesNo) == DialogResult.No) return; DeleteCustomerRequest request = new DeleteCustomerRequest(); request.token = this.Token; var customer = dgvList.CurrentRow.DataBoundItem as Customer; request.id = customer.ID; SDKSync<CommonResponse>.CreateInstance(this).Execute(request, Delete_Callback); }
public override async Task <DeleteCustomerResponse> DeleteCustomer(DeleteCustomerRequest request, ServerCallContext context) { if (await repository.DeleteCustomer(Guid.Parse(request.Id))) { return(new DeleteCustomerResponse { Id = request.Id, Result = "SUCCESS" }); } return(new DeleteCustomerResponse { Id = string.Empty, Result = "FAILURE" }); }
public async Task <IActionResult> Delete(string id) { var request = new DeleteCustomerRequest(new DeleteCustomerModel() { Id = id }); var result = await _mediator.Send(request); if (result.IsDeleted == false) { return(BadRequest()); } return(NoContent()); }
public void DeleteCustomer(int customerId) { try { DeleteCustomerRequest request = new DeleteCustomerRequest(); request.CustomerId = customerId; DeleteCustomerResponse response = Service.DeleteCustomer(request); } catch (Exception ex) { if (ExceptionPolicy.HandleException(ex, "PL Policy")) { throw; } } }
/// <summary> /// Deletes the customer. --Robin /// </summary> /// <param name="id">The id.</param> /// <returns></returns> public bool DeleteCustomer(int id) { DeleteCustomerRequest request = new DeleteCustomerRequest(); request.Id = id; DeleteCustomerResponse response = MyChannelFactory.CreateChannel().DeleteCustomer(request); if (response.IsFailed) { ILog log = log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); log.Error("error", new Exception(response.Message)); log.Fatal("fatal", new Exception(response.Message)); throw new Exception("We have a error!"); } return(true); }
/// <summary> /// Deletes the customer. /// </summary> /// <param name="request">The request.</param> /// <returns></returns> public DeleteCustomerResponse DeleteCustomer(DeleteCustomerRequest request) { CustomerService service = new CustomerService(); DeleteCustomerResponse response = new DeleteCustomerResponse(); try { service.DeleteCustomer(request.Id); } catch (System.Exception ex) { response.IsFailed = true; response.Message = ex.Message; } return(response); }
public SuccessResponse Delete(DeleteCustomerRequest request) { try { var customer = _customerRepository.FindBy(request.Id); customer.ThrowExceptionIfRecordIsNull(); _customerRepository.Remove(customer); return(new SuccessResponse { IsSuccess = true }); } catch (DataAccessException) { throw new ApplicationException(); } }
public void DeleteCustomerResourceNames() { moq::Mock <CloudChannelService.CloudChannelServiceClient> mockGrpcClient = new moq::Mock <CloudChannelService.CloudChannelServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); DeleteCustomerRequest request = new DeleteCustomerRequest { CustomerName = CustomerName.FromAccountCustomer("[ACCOUNT]", "[CUSTOMER]"), }; wkt::Empty expectedResponse = new wkt::Empty { }; mockGrpcClient.Setup(x => x.DeleteCustomer(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); CloudChannelServiceClient client = new CloudChannelServiceClientImpl(mockGrpcClient.Object, null); client.DeleteCustomer(request.CustomerName); mockGrpcClient.VerifyAll(); }
public async stt::Task DeleteCustomerResourceNamesAsync() { moq::Mock <CloudChannelService.CloudChannelServiceClient> mockGrpcClient = new moq::Mock <CloudChannelService.CloudChannelServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); DeleteCustomerRequest request = new DeleteCustomerRequest { CustomerName = CustomerName.FromAccountCustomer("[ACCOUNT]", "[CUSTOMER]"), }; wkt::Empty expectedResponse = new wkt::Empty { }; mockGrpcClient.Setup(x => x.DeleteCustomerAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <wkt::Empty>(stt::Task.FromResult(expectedResponse), null, null, null, null)); CloudChannelServiceClient client = new CloudChannelServiceClientImpl(mockGrpcClient.Object, null); await client.DeleteCustomerAsync(request.CustomerName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); await client.DeleteCustomerAsync(request.CustomerName, st::CancellationToken.None); mockGrpcClient.VerifyAll(); }
public async Task If_Invalid_Request_Is_Sent_Cannot_Delete_Customer() { // // Arrange // var customerService = GetCustomerService(); var emptyRequest = new DeleteCustomerRequest(string.Empty); var nullIdRequest = new DeleteCustomerRequest(null); DeleteCustomerRequest nullRequest = null; // // Act // var tasks = new[] { emptyRequest, nullIdRequest, nullRequest }.Select(x => customerService.DeleteCustomerAsync(x)); var operationResults = await Task.WhenAll(tasks); // // Assert // Assert.False(operationResults.All(x => x.Status)); }
public async Task TestNotFound() { // Arrange Mock <IDataRepository <Customer, Guid> > mockRepository = new Mock <IDataRepository <Customer, Guid> >(); Guid id = new Guid("b7c2acaa-ad72-47b3-b858-26357cf14fbb"); mockRepository.Setup(m => m.FindAsync(id, default)).Returns(new ValueTask <Customer>((Customer)null)); DeleteCustomerRequest request = new DeleteCustomerRequest() { Id = id }; DeleteCustomerCommand sut = new DeleteCustomerCommand(MockHelpers.GetLogger <DeleteCustomerCommand>(), mockRepository.Object); // Act await Assert.ThrowsExceptionAsync <NotFoundException>(async() => await sut.Handle(request, default)); // Assert mockRepository.VerifyAll(); mockRepository.Verify(m => m.FindAsync(id, default), Times.Once); mockRepository.Verify(m => m.Delete(It.IsAny <Customer>()), Times.Never); }
/// <remarks/> public void DeleteCustomerAsync(DeleteCustomerRequest DeleteCustomerRequest) { this.DeleteCustomerAsync(DeleteCustomerRequest, null); }
/// <remarks/> public void DeleteCustomerAsync(DeleteCustomerRequest DeleteCustomerRequest, object userState) { if ((this.DeleteCustomerOperationCompleted == null)) { this.DeleteCustomerOperationCompleted = new System.Threading.SendOrPostCallback(this.OnDeleteCustomerOperationCompleted); } this.InvokeAsync("DeleteCustomer", new object[] { DeleteCustomerRequest}, this.DeleteCustomerOperationCompleted, userState); }