Exemple #1
0
        public async Task <UserModel> ToggleAccountStatus(string userId, ChangeAccountStatusModel changeAccountStatusModel)
        {
            if (string.IsNullOrEmpty(userId))
            {
                throw new BadRequestException(HttpStatusCode.BadRequest.ToString(), "Empty User Id");
            }

            var user = await _userService.GetUserAsync(userId);

            if (changeAccountStatusModel.IsActive.HasValue)
            {
                user.IsActive = changeAccountStatusModel.IsActive.Value;
            }

            if (changeAccountStatusModel.IsVerifyRequired.HasValue)
            {
                user.IsVerifyRequired = changeAccountStatusModel.IsVerifyRequired.Value;
            }

            var result = await _userService.UpdateUserAsync(userId, user);

            return(result);
        }
        public async Task <IHttpActionResult> ToggleAccountStatus([FromUri] string userId, [FromBody] ChangeAccountStatusModel changeAccountStatusModel)
        {
            var result = await _adminService.ToggleAccountStatus(userId, changeAccountStatusModel);

            return(Ok(result));
        }