示例#1
0
        public async Task <IActionResult> ModeratorDelete(ModeratorDeleteDto input)
        {
            var token = GetToken();

            if (!String.IsNullOrEmpty(token))
            {
                var loggedUserId = LoginHelper.GetClaim(token, "UserId");
                input.ModeratorId = Guid.Parse(loggedUserId);
            }

            var isAdmin = await _communityUserRepository.GetAll()
                          .FirstOrDefaultAsync(x =>
                                               x.IsDeleted == false && x.IsAdmin && x.UserId == input.ModeratorId && x.Community.Slug == input.Slug);

            if (isAdmin == null)
            {
                return(Unauthorized());
            }

            await _postAppService.DeleteModerator(input);

            return(Ok());
        }