private void CreateEmailProfile(string name, string type) { var languages = ObjectFactory.Instance.Resolve <ILanguageService>().GetAllLanguages(); var orderConfirmationType = EmailType.FirstOrDefault(x => x.Name == type); var emailProfile = EmailProfile.SingleOrDefault(p => p.Name == name) ?? new EmailProfile(); emailProfile.Name = name; emailProfile.Deleted = false; foreach (var language in languages) { var emailContent = emailProfile.EmailContents.SingleOrDefault(x => x.CultureCode == language.CultureCode && x.EmailType.Name == type) ?? new EmailContent(); emailContent.ContentId = "0d0c0ed6-7144-4a9a-a7d1-3284c8d459d1"; emailContent.CultureCode = language.CultureCode; emailContent.EmailProfile = emailProfile; emailContent.EmailType = orderConfirmationType; emailContent.Subject = "OrderConfirmation email"; emailContent.Save(); } emailProfile.Save(); }