public async Task <ActionResult> RequestTeam([FromQuery] string authorizationCode) { var authorizationLink = await this.useCase.GetAuthorizationLinkByCode(authorizationCode); var deserializedMailAddress = authorizationLink.UniqueKey; var model = new RequestTeamViewModel(); model.RepresentativeEmailAddress = deserializedMailAddress; return(this.View(model)); }
public async Task <ActionResult> RequestTeam([Bind( "TeamType", "TeamName", "TeamAbbreviatedName", "RepresentativeName", "RepresentativeEmailAddress", "TelephoneNumber", "Address", "CoachName", "CoachEmailAddress")] RequestTeamViewModel model) { if (!this.ModelState.IsValid) { return(this.View(model)); } var normalizedMailAddress = userManager.NormalizeEmail(model.RepresentativeEmailAddress); var duplicatedMailAddress = await userManager.FindByEmailAsync(normalizedMailAddress); if (duplicatedMailAddress != null) { model.IsDuplicated = true; return(this.View(model)); } // AspNetUserへの登録 var applicationUser = new ApplicationUser(); applicationUser.UserName = model.RepresentativeEmailAddress; applicationUser.Email = model.RepresentativeEmailAddress; await this.userManager.CreateAsync(applicationUser); // teamsへの登録 Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); var dto = model.ToDto(); await this.useCase.RequestTeamNewRegistration(dto); // 登録完了通知メールの送信 await this.useCase.SendRequestTeamNewRegistrationMail(model.RepresentativeEmailAddress); return(Redirect("/")); }