public async Task<IActionResult> Post( [FromRoute]Guid userAccountId, [FromBody]ChangeEmailInputModel inputModel) { // Check if user account to change exists UserAccount userAccount = await this._userAccountService .LoadByIdAsync(userAccountId); if (userAccount == null) { return this.NotFound(); } // Check if new email address is already taken if (await this._userAccountService .LoadByEmailAsync(inputModel.Email) != null) { return this.BadRequest( nameof(inputModel.Email), "The Email field is invalid, Email already taken." ); } // Send confirmation mail to user if (!inputModel.Force) { return await this.DoubleOptInAsync(userAccount, inputModel); } // Update user directly without sending confirmation email await this._userAccountService.SetNewEmailAsync( userAccount, inputModel.Email.ToLower() ); return this.Ok(); }