Esempio n. 1
0
        public async Task <IActionResult> RemoveFromMeetAsync(
            [FromBody] AssignToMeetForm form, CancellationToken ct)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(new ApiError(ModelState)));
            }

            var canRemoveScribe = await _authService
                                  .AuthorizeAsync(User, "IsAdminOrTimer");

            if (canRemoveScribe.Succeeded)
            {
                var(succeeded, error) = await _userService.AssignToMeetAsync(form, ct);

                if (succeeded)
                {
                    return(Ok());
                }
            }

            return(BadRequest(new ApiError
            {
                Message = "Failed to remove scribe to meet"
            }));
        }
Esempio n. 2
0
        public async Task <(bool Succeeded, string Error)> RemoveFromMeetAsync(
            AssignToMeetForm form, CancellationToken ct)
        {
            var user = await _userManager.FindByIdAsync(form.UserId.ToString());

            if (user != null)
            {
                IdentityResult ir = await _userManager
                                    .RemoveClaimAsync(user, new Claim(DefaultClaims.Scribe, form.meetId.ToString()));

                return(true, null);
            }

            return(false, "User not found");
        }
Esempio n. 3
0
        public async Task <(bool Succeeded, string Error)> AssignToMeetAsync(
            AssignToMeetForm form, CancellationToken ct)
        {
            var user = await _userManager.FindByIdAsync(form.UserId.ToString());

            if (user != null)
            {
                IdentityResult ir = await _userManager
                                    .AddClaimAsync(user, new Claim(DefaultClaims.Scribe, form.meetId.ToString()));

                return(ir.Succeeded, (ir.Succeeded? null : "Failed to add user as scribe"));
            }

            return(false, "User not found");
        }