public async Task <IActionResult> DeleteProfileAsync(
            [BindRequired, FromQuery] string profileId,
            [BindRequired, FromQuery] Iri activityId,
            [FromQuery] Guid?registration = null,
            CancellationToken cancelToken = default)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var profile = await _mediator.Send(
                GetActivityProfileQuery.Create(activityId, profileId, registration),
                cancelToken);

            if (profile == null)
            {
                return(NotFound());
            }

            if (Request.TryConcurrencyCheck(profile.Document.Checksum, profile.Document.LastModified, out int statusCode))
            {
                return(StatusCode(statusCode));
            }

            await _mediator.Send(DeleteActivityProfileCommand.Create(
                                     profileId, activityId, registration), cancelToken);

            return(NoContent());
        }
Ejemplo n.º 2
0
        public async Task <ActivityProfileDocument> Handle(GetActivityProfileQuery request, CancellationToken cancellationToken)
        {
            ActivityProfileEntity profile = await GetProfile(request.ActivityId, request.ProfileId, request.Registration, cancellationToken);

            return(_mapper.Map <ActivityProfileDocument>(profile));
        }