private async Task <IdentityResults.Password> AddShortTermParticipant(ShortTermParticipant user) { await _session.StoreAsync(user); await _session.SaveChangesAsync(); return(new IdentityResults.Password() { IsSuccess = true }); }
public async Task <Answer> CreateParticipant(ParticipantCreateUpdateViewModel viewmodel) { var answer = ValidateParticipantFields(viewmodel); if (answer.AnswerType != AnswerType.Success) { return(answer); } IParticipant model; ConventionEngagement engagement = new ConventionEngagement { ConventionId = Actor.ManagedConvention.ConventionId, ConventionStartDate = Actor.ManagedConvention.Days .Min(x => x.Date) .ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), Payment = new PaymentInvoice() }; if (viewmodel.Email.IsEmptyString()) { model = new ShortTermParticipant { CreatedById = Actor.Me.Id }; } else { model = new LongTermParticipant { UserName = viewmodel.Email, Email = viewmodel.Email, IsAllowingPromotions = viewmodel.IsAllowingPromotions, }; engagement.IsLongTerm = true; } model.FullName = viewmodel.FullName; model.PhoneNumber = viewmodel.PhoneNumber ?? string.Empty; model.YearOfBirth = viewmodel.YearOfBirth; var result = await Identities.AddNewParticipant(model); engagement.ParticipantId = model.Id; if (result.IsSuccess) { Session.Store(engagement); Session.SaveChanges(); } if (result.IsSuccess && result.IsLongTerm) { await Hub.SendCreationPasswordAsync(model as LongTermParticipant, result.Token); } if (result.IsSuccess == false) { return(Answer.Error(result.Errors?.AsJson())); } return(Answer.Success); }