private void MapViewModelsToCommands() { this.CreateMap <InviteUserViewModel, InviteUserCommand>() .ConstructUsing(source => new InviteUserCommand(LocationId.With(Guid.Parse(source.Id)), new Email(source.Email))); this.CreateMap <DeleteInvitationViewModel, DeleteInvitationCommand>() .ConstructUsing(source => new DeleteInvitationCommand(LocationId.With(Guid.Parse(source.Id)), InvitationId.With(Guid.Parse(source.Invitation)))); }
public async Task <IActionResult> RejectInvitation([CustomizeValidator(Skip = true)][FromBody] RejectInvitationViewModel model) { ValidationResult validationResults = await this.rejectInvitationValidator .ValidateAsync(model ?? new RejectInvitationViewModel(), CancellationToken.None).ConfigureAwait(false); validationResults.AddToModelState(this.ModelState, null); if (!this.ModelState.IsValid) { return(this.BadRequest(this.ModelState)); } Location location = await this.GetLocationByInvitationCode(model?.Code.ToString(), CancellationToken.None) .ConfigureAwait(false); if (location == null) { this.ModelState.AddModelError("Code", LocationResources.InvitationNotFound); return(this.BadRequest(this.ModelState)); } IExecutionResult result = await this.commandBus .PublishAsync( new RejectInvitationCommand(LocationId.With(Guid.Parse(location.Id)), InvitationId.With(Guid.Parse(model.Code.ToString()))), CancellationToken.None) .ConfigureAwait(false); if (!result.IsSuccess) { return(this.BadRequest()); } return(this.Ok(await this.GetInvitationByCode(location.Id, model.Code.ToString(), CancellationToken.None) .ConfigureAwait(false))); }
public InvitationById(string location, string invitation) { this.Location = LocationId.With(Guid.Parse(location)).Value; this.Invitation = InvitationId.With(Guid.Parse(invitation)).Value; }
public LocationByInvitationId(string id) { this.Id = InvitationId.With(Guid.Parse(id)).Value; }
public OpenInvitationExists(string invitation) { this.Invitation = InvitationId.With(Guid.Parse(invitation)).Value; }