public async Task SendFirstProjectEmail(string userId, string userAgent) { if (!_settings.EmailNotifications) { return; } string template; EmailTemplate templateId; ProductType product = _productIdExtractor.Get(userAgent); switch (product) { case ProductType.ImageShack: template = PortalResources.UserRegistrationImageshack; templateId = EmailTemplate.FirstProjectExtension; break; case ProductType.CicIPad: case ProductType.CicMac: case ProductType.CicPc: template = PortalResources.ProjectFirstCic; templateId = EmailTemplate.FirstProjectCic; break; case ProductType.TaggerAndroid: case ProductType.TaggerIPhone: template = PortalResources.ProjectFirstTagger; templateId = EmailTemplate.FirstProjectOtherProducts; break; case ProductType.Standalone: template = PortalResources.UserRegistration; templateId = EmailTemplate.Registration; break; default: return; } bool emailAlreadySendOnce = await CheckEmailBeenSend(userId, templateId); if (emailAlreadySendOnce) { return; } DomainUser user = await _userService.GetAsync(userId); if (user == null || string.IsNullOrEmpty(user.Email)) { return; } var email = new SendEmailDomain { Body = string.Format(template, user.Name), Address = _settings.EmailAddressInfo, DisplayName = Emails.SenderDisplayName, Subject = Emails.SubjectFirstTag, Emails = new List <string> { user.Email }, UserId = userId, Template = templateId }; await _emailSenderService.SendAndLogEmailAsync(email); }