示例#1
0
        public async Task <bool> DeleteUserByIdAsync(DeleteUserByIdRequest request)
        {
            var result = await _userRepository.DeleteUserByIdAsync(request);

            //await _userPublisher.Publish(request);
            return(result);
        }
示例#2
0
        public async Task <HttpResponseMessage> DeleteUser(DeleteUserByIdRequest deleteUserRequest)
        {
            var content = IntegrationHttpRequest.CreateQuery(deleteUserRequest);
            HttpResponseMessage response = await client.DeleteAsync(UrlBase + String.Format("api/v1/delete-user?{0}", content));

            return(response);
        }
示例#3
0
        public virtual DeleteUserByIdResponse DeleteUserById(DeleteUserByIdRequest request)
        {
            var response = new DeleteUserByIdResponse();

            try {
                // Raise Initialization Event
                var initialization = DeleteUserByIdInitialization;
                if (initialization != null)
                {
                    initialization(request, response);
                }
                // Raise Execute Event
                var execute = DeleteUserByIdExecute;
                if (execute != null)
                {
                    response = execute(request);
                }
                // Raise Complete Event
                var complete = DeleteUserByIdComplete;
                if (complete != null)
                {
                    complete(request, response);
                }
            }
            catch (Exception exception) {
                // Raise Error Event
                var error = DeleteUserByIdError;
                if (error != null)
                {
                    error(request, response, exception);
                }
            }
            return(response);
        }
示例#4
0
        public async Task <bool> DeleteUserByIdAsync(DeleteUserByIdRequest request)
        {
            var result = await DeleteAsync <User.DomainModel.User>(request.Id);

            await SaveAsync();

            return(result);
        }
示例#5
0
        public async Task <IActionResult> DeleteUser([FromRoute] int id)
        {
            var request = new DeleteUserByIdRequest()
            {
                Id = id
            };

            return(await this.HandleRequest <DeleteUserByIdRequest, DeleteUserByIdResponse>(request));
        }
        public async Task TestDeleteUser(DeleteUserByIdRequest delcom, ObjectResult resultAction, bool elementCreated = false)
        {
            Guid createdtransactionId = UserComponentsValues.GetUserAviability();

            delcom.Id = elementCreated == true ? createdtransactionId : delcom.Id;

            HttpResponseMessage actionResult = await _userAPI.DeleteUser(delcom);

            base.CheckAssert(actionResult, resultAction);
        }
示例#7
0
        public async Task TestDeleteNotification(DeleteUserByIdRequest delnot, ObjectResult resultAction, bool elementCreated = false)
        {
            UserResponse defaultNotification = await this.CreatedDefaultUser();

            //Guid createdtransactionId = CompanyComponentsValues.GetCompanyAviability();

            delnot.Id = elementCreated == true ? defaultNotification.Id : delnot.Id;

            IActionResult actionResult = await this.DeleteUser(delnot);

            base.CheckAssert(actionResult, resultAction);
        }
        public async Task When_an_authenticated_user_is_deleting_an_user_should_return_Ok()
        {
            var userGiven = Given.Any_user();
            var request   = new DeleteUserByIdRequest
            {
                Id = userGiven.Id
            };

            var response = await _host
                           .Server
                           .CreateHttpApiRequest <UsersController>(c => c.DeleteUser(request))
                           .SendAsync(HttpMethod.Delete.ToString());

            response.StatusCode.Should().Be(HttpStatusCode.OK);
        }
示例#9
0
        public async Task <bool> Handle(DeleteUserByIdRequest message, IOutputPort <DeleteUserByIdResponse> outputPort)
        {
            if (message.Id != 0)
            {
                // confirm the user has been deleted successfully
                var result = await _userRepository.DeleteById(message.Id);

                if (result)
                {
                    // generate response
                    outputPort.Handle(new DeleteUserByIdResponse("User has been deleted successfully.", true));
                    return(true);
                }
            }
            outputPort.Handle(new DeleteUserByIdResponse(new[] { new Error("delete_user_by_id_failure", "Invalid User Id.") }));
            return(false);
        }
示例#10
0
        public override DeleteUserByIdResponse OnDeleteUserByIdExecute(DeleteUserByIdRequest request)
        {
            DeleteUserByIdResponse response = new DeleteUserByIdResponse();

            try
            {
                var spec = new UsuarioByIdSpec(request.Id);
                var user = _usuarioRepository.Get(spec);

                _usuarioRepository.Delete(user);
                _unitOfWork.Commit();
            }
            catch (Exception ex)
            {
                response.Exception = ex;
            }
            return(response);
        }
示例#11
0
        private async Task <IActionResult> DeleteUser(DeleteUserByIdRequest deleteUserRequest)
        {
            var options = new DbContextOptionsBuilder <Context>()
                          .UseInMemoryDatabase(databaseName: "User")
                          .Options;


            // Run the test against one instance of the context
            using (var context = new Context(options))
            {
                var repository = new UserRepository(context, AutomapperSingleton.Mapper);
                var service    = new UserService(repository, AutomapperSingleton.Mapper, _userPublisher);
                var controller = new UserController(service, AutomapperSingleton.Mapper);

                Mock <HttpRequest> mockCreateRequest = MockHttpRequest.CreateMockQuery(deleteUserRequest.Id);
                return(await controller.DeleteUserAsync(mockCreateRequest.Object, _logger)); //as GridController;
            }
        }
        public void DeleteUserByIdValidator_ValidateItDoesntHaveAValue_ItHAveToBeValid()
        {
            const bool idExistResult = true;
            const int  id            = 0;

            var request = new DeleteUserByIdRequest {
                Id = id
            };
            var idExistMock = new Mock <IIdExists>();

            idExistMock.Setup(x => x.Query(request.Id, new CancellationToken())).ReturnsAsync(idExistResult);

            var validator         = new DeleteUserByIdValidator(idExistMock.Object);
            var validationContext = new ValidationContext <DeleteUserByIdRequest>(request);

            var validationResult = validator.Validate(validationContext);

            validationResult.IsValid.Should().BeFalse();
        }
示例#13
0
 /*
  * [HttpDelete]
  * public IActionResult Delete([FromODataUri] int id)
  * {
  *  return Ok(id);
  * }
  *
  *
  * /*/
 public IActionResult Delete([FromBody] DeleteUserByIdRequest request)
 {
     return(Ok(new UserServerObjectService().DeleteUserById(request)));
 }
示例#14
0
        public async Task Publish(DeleteUserByIdRequest user)
        {
            var @event = _mapper.Map <UserDeleted>(user);

            await _eventPublisher.Publish(@event);
        }
示例#15
0
 public abstract DeleteUserByIdResponse OnDeleteUserByIdExecute(DeleteUserByIdRequest request);
示例#16
0
 public async Task Publish(DeleteUserByIdRequest user)
 {
     await Task.Run(() => CreateUserRequest());
 }