public async Task <ContactAggregate> Handle(UpdateContactAddressesCommand request, CancellationToken cancellationToken) { var contactAggregate = await _contactAggregateRepository.GetContactByIdAsync(request.ContactId); contactAggregate.UpdateContactAddresses(request.Addresses); await _contactAggregateRepository.SaveAsync(contactAggregate); return(await _contactAggregateRepository.GetContactByIdAsync(request.ContactId)); }
public async Task <IdentityResult> Handle(UpdatePersonalDataCommand request, CancellationToken cancellationToken) { var result = IdentityResult.Success; using (var userManager = _userManagerFactory()) { var user = await userManager.FindByIdAsync(request.UserId); if (user == null) { return(IdentityResult.Failed()); } if (!IsUserEditable(user.UserName)) { return(IdentityResult.Failed(new IdentityError { Description = "It is forbidden to edit this user." })); } if (request.PersonalData?.Email != null && user.Email != request.PersonalData?.Email) { user.Email = request.PersonalData.Email; result = await userManager.UpdateAsync(user); } var contactAggregate = await _contactAggregateRepository.GetContactByIdAsync(user.MemberId); if (contactAggregate != null) { contactAggregate.UpdatePersonalDetails(request.PersonalData); await _contactAggregateRepository.SaveAsync(contactAggregate); } } return(result); }
public UserType(IContactAggregateRepository contactAggregateRepository) { Field(x => x.AccessFailedCount); Field(x => x.CreatedBy, true); Field(x => x.CreatedDate, true); Field(x => x.Email, true); Field(x => x.EmailConfirmed); Field(x => x.Id); Field(x => x.IsAdministrator); Field(x => x.LockoutEnabled); Field <DateTimeGraphType>("lockoutEnd", resolve: x => x.Source.LockoutEnd); Field(x => x.MemberId, true); Field(x => x.ModifiedBy, true); Field(x => x.ModifiedDate, true); Field(x => x.NormalizedEmail, true); Field(x => x.NormalizedUserName, true); Field(x => x.PasswordExpired); Field(x => x.PhoneNumber, true); Field(x => x.PhoneNumberConfirmed); Field(x => x.PhotoUrl, true); Field <ListGraphType <RoleType> >("roles", resolve: x => x.Source.Roles); Field <ListGraphType <StringGraphType> >("permissions", resolve: x => x.Source.Roles?.SelectMany(r => r.Permissions?.Select(p => p.Name))); Field(x => x.SecurityStamp); Field(x => x.StoreId, true); Field(x => x.TwoFactorEnabled); Field(x => x.UserName); Field(x => x.UserType, true); AddField(new FieldType { Name = "Contact", Description = "The associated contact info", Type = GraphTypeExtenstionHelper.GetActualType <ContactType>(), Resolver = new AsyncFieldResolver <ApplicationUser, ContactAggregate>(context => contactAggregateRepository.GetContactByIdAsync(context.Source.MemberId)) }); }
public Task <ContactAggregate> Handle(GetContactByIdQuery request, CancellationToken cancellationToken) { return(_contactAggregateRepository.GetContactByIdAsync(request.ContactId)); }