public async Task <IActionResult> Subscribe(SubscribeInputViewModel inputModel) { var userId = this.usersService.GetLoggedUserId(); var user = await this.usersService.GetLoggedUserByIdAsync(userId); if (!this.ModelState.IsValid) { return(this.View(inputModel)); } if (user.HasSubscribe) { this.TempData["SubscribeMessage"] = GlobalConstants.UserSubscribeDenied; return(this.RedirectToAction("Index")); } else { this.TempData["SubscribeMessage"] = GlobalConstants.UserSubscribeSuccess; await this.usersService.UserSubscribeAsync(user); await this.SendEmail(inputModel); return(this.RedirectToAction("Index")); } }
private async Task SendEmail(SubscribeInputViewModel inputModel) { await this.emailSender.SendEmailAsync( GlobalConstants.ApplicationSendEmail, GlobalConstants.AdministratorRoleName, inputModel.Email, GlobalConstants.SubscribeEmailSubject, GlobalConstants.SubscribeEmailContent); await this.emailSender.SendEmailAsync( GlobalConstants.ApplicationSendEmail, GlobalConstants.AdministratorRoleName, GlobalConstants.AdministratorReceiveEmail, GlobalConstants.AdministratorSubscribeEmailSubject, string.Format(GlobalConstants.AdministratorSubscribeEmailContent, inputModel.Email)); }