Exemple #1
0
        public async Task <IHttpActionResult> DeleteUser(string id)
        {
            _logger.Debug(string.Format("Begin. Id: [{0}]", id));
            var ndUser = await NdUserManager.FindByIdAsync(id);

            if (ndUser != null)
            {
                IdentityResult result = await NdUserManager.DeleteAsync(ndUser);

                if (!result.Succeeded)
                {
                    _logger.Error(string.Format(
                                      "Delete user failed. Id: [{0}], Reason: [{1}]",
                                      id,
                                      string.Join(Environment.NewLine, result.Errors)));
                    return(GetErrorResult(result));
                }

                _logger.Debug(string.Format("User deleted successfully. Id: [{0}]", id));
                return(Ok());
            }

            _logger.Debug(string.Format("User was not found [id: {0}]", id));
            return(NotFound());
        }