Beispiel #1
0
        internal DeleteUserProfileResponse DeleteUserProfile(DeleteUserProfileRequest request)
        {
            var marshaller   = new DeleteUserProfileRequestMarshaller();
            var unmarshaller = DeleteUserProfileResponseUnmarshaller.Instance;

            return(Invoke <DeleteUserProfileRequest, DeleteUserProfileResponse>(request, marshaller, unmarshaller));
        }
Beispiel #2
0
        /// <summary>
        /// Initiates the asynchronous execution of the DeleteUserProfile operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the DeleteUserProfile operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/codestar-2017-04-19/DeleteUserProfile">REST API Reference for DeleteUserProfile Operation</seealso>
        public Task <DeleteUserProfileResponse> DeleteUserProfileAsync(DeleteUserProfileRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller   = new DeleteUserProfileRequestMarshaller();
            var unmarshaller = DeleteUserProfileResponseUnmarshaller.Instance;

            return(InvokeAsync <DeleteUserProfileRequest, DeleteUserProfileResponse>(request, marshaller,
                                                                                     unmarshaller, cancellationToken));
        }
Beispiel #3
0
        /// <summary>
        /// Initiates the asynchronous execution of the DeleteUserProfile operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the DeleteUserProfile operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/codestar-2017-04-19/DeleteUserProfile">REST API Reference for DeleteUserProfile Operation</seealso>
        public virtual Task <DeleteUserProfileResponse> DeleteUserProfileAsync(DeleteUserProfileRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = DeleteUserProfileRequestMarshaller.Instance;
            options.ResponseUnmarshaller = DeleteUserProfileResponseUnmarshaller.Instance;

            return(InvokeAsync <DeleteUserProfileResponse>(request, options, cancellationToken));
        }
Beispiel #4
0
        internal virtual DeleteUserProfileResponse DeleteUserProfile(DeleteUserProfileRequest request)
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = DeleteUserProfileRequestMarshaller.Instance;
            options.ResponseUnmarshaller = DeleteUserProfileResponseUnmarshaller.Instance;

            return(Invoke <DeleteUserProfileResponse>(request, options));
        }
Beispiel #5
0
        public ActionResult <DeleteUserProfileResponse> DeleteProsumers_Consumers_Prifile(long id)
        {
            var deleteUserProfileRequest = new DeleteUserProfileRequest
            {
                Id = id
            };
            var deleteUserProfileResponse = _userprofileService.DeleteUserProfile(deleteUserProfileRequest);

            return(deleteUserProfileResponse);
        }
        public DeleteUserProfileResponse DeleteUserProfile(DeleteUserProfileRequest deleteUserProfileRequest)
        {
            var userprofile = _userprofileRepository.FindUserProfileById(deleteUserProfileRequest.Id);

            _userprofileRepository.DeleteUserProfile(userprofile);
            var userprofileDto = _messageMapper.MapToUserProfileDto(userprofile);

            return(new DeleteUserProfileResponse
            {
                UserProfile = userprofileDto
            });
        }
Beispiel #7
0
        /// <summary>
        /// The DeleteUserProfile
        /// </summary>
        /// <param name="userToken">The userToken<see cref="UserToken"/></param>
        /// <param name="request">The request<see cref="DeleteUserProfileRequest"/></param>
        /// <returns>The <see cref="Task{ResponseData{DeleteUserProfileResponse}}"/></returns>
        public async Task <ResponseData <DeleteUserProfileResponse> > DeleteUserProfile(UserToken userToken, DeleteUserProfileRequest request)
        {
            try
            {
                var response = new ResponseData <DeleteUserProfileResponse>();

                if (userToken == null)
                {
                    throw new UnauthorizedAccessException();
                }

                var profile = await CheckAccess(userToken, request.Id);

                if (profile == null)
                {
                    throw new ServiceException("Неправильный пользователь");
                }

                _ctx.Remove(profile);
                await _ctx.SaveChangesAsync();

                var user = await _userManager.Users.FirstOrDefaultAsync(p => p.Id == request.Id);

                var blockResult = await _userManager.SetLockoutEnabledAsync(user, true);

                if (!blockResult.Succeeded)
                {
                    throw new ServiceException("Не удалось заблокировать пользователь");
                }

                response.code = BaseStatus.Success;
                response.data = new DeleteUserProfileResponse
                {
                    Status = "ok",
                };
                return(response);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "could not delete");
                return(new ResponseData <DeleteUserProfileResponse>
                {
                    code = BaseStatus.Exception,
                    message = "Не удалось удалить пользователя",
                    description = ex.Message
                });
            }
        }