public virtual Invite InviteMember(Member member, IModelFactory factory) { if (!members.Contains(member) && !(member is INullObject)) { var invite = factory.CreateInvite(this, member); invites.Add(invite); return(invite); } return(Invite.Null); }
public async Task <IApiResult> Handle(InviteMemberCommand command, CancellationToken cancellationToken) { var invitingGuild = await _unit.Guilds.GetByIdAsync(command.GuildId, false, cancellationToken); var invitedMember = await _unit.Members.GetByIdAsync(command.MemberId, false, cancellationToken); var invite = _factory.CreateInvite(invitingGuild, invitedMember); invite = await _unit.Invites.InsertAsync(invite, cancellationToken); return(new SuccessCreatedResult(invite, command)); }