private void AddMails(IPlatformDataSource source, Guid adminId, Guid mainGroupId, string directory, List <MailContentTemplate> templateContent, EntityType mailType, string from, DateTime date, string[] supportedCultures)
        {
            var           allFiles  = Directory.GetFiles(directory).Where(f => !f.ToLower().Split('\\').Last().StartsWith("mailtemplate") && f.EndsWith(".html"));
            List <string> mailFiles = new List <string>();

            foreach (var file in allFiles)
            {
                var normalisedName = file.Contains("_") ? file.Split('_').First() + "." + file.Split('.').Last() : file;

                if (!mailFiles.Contains(normalisedName))
                {
                    mailFiles.Add(normalisedName);
                }
            }

            foreach (var mailFile in mailFiles)
            {
                var mailData = this._fileSystemWrapper.GetHtmlTemplate(directory, mailFile.Split('\\').Last().Split('.').First(), null);

                var entity = new PlatformEntity
                {
                    Id          = Guid.NewGuid(),
                    GroupId     = mainGroupId,
                    Url         = mailFile.Split('\\').Last().Split('.').First().ToLower(),
                    EntityType  = mailType,
                    OwnerUserId = adminId
                };

                source.Save(entity);

                foreach (var data in mailData.Where(t => supportedCultures.Contains(t.Culture.ToLower())))
                {
                    var template = templateContent.First(t => t.Culture == data.Culture);

                    var content = new MailContent
                    {
                        Id                = Guid.NewGuid(),
                        EntityId          = entity.Id,
                        Entity            = entity,
                        Template          = template,
                        TemplateId        = template.Id,
                        Culture           = data.Culture,
                        VersionNumber     = 1,
                        Name              = mailFile.Split('\\').Last().Split('.').First(),
                        CreatedByUserId   = adminId,
                        CreatedOn         = date,
                        UpdatedByUserId   = adminId,
                        UpdatedOn         = date,
                        IsCurrentVersion  = true,
                        PublishedByUserId = adminId,
                        PublishedOn       = date,
                        From              = from,
                        Subject           = data.Subject,
                        Body              = data.Body
                    };

                    source.Save(content);
                }
            }
        }
        private void AddMails(IPlatformDataSource source, Guid adminId, Guid mainGroupId, string directory, List<MailContentTemplate> templateContent, EntityType mailType, string from, DateTime date, string[] supportedCultures)
        {
            var allFiles = Directory.GetFiles(directory).Where(f => !f.ToLower().Split('\\').Last().StartsWith("mailtemplate") && f.EndsWith(".html"));
            List<string> mailFiles = new List<string>();

            foreach (var file in allFiles)
            {
                var normalisedName = file.Contains("_") ? file.Split('_').First() + "." + file.Split('.').Last() : file;

                if (!mailFiles.Contains(normalisedName))
                {
                    mailFiles.Add(normalisedName);
                }
            }

            foreach (var mailFile in mailFiles)
            {
                var mailData = this._fileSystemWrapper.GetHtmlTemplate(directory, mailFile.Split('\\').Last().Split('.').First(), null);

                var entity = new PlatformEntity
                {
                    Id = Guid.NewGuid(),
                    GroupId = mainGroupId,
                    Url = mailFile.Split('\\').Last().Split('.').First().ToLower(),
                    EntityType = mailType,
                    OwnerUserId = adminId
                };

                source.Save(entity);

                foreach (var data in mailData.Where(t => supportedCultures.Contains(t.Culture.ToLower())))
                {
                    var template = templateContent.First(t => t.Culture == data.Culture);

                    var content = new MailContent
                    {
                        Id = Guid.NewGuid(),
                        EntityId = entity.Id,
                        Entity = entity,
                        Template = template,
                        TemplateId = template.Id,
                        Culture = data.Culture,
                        VersionNumber = 1,
                        Name = mailFile.Split('\\').Last().Split('.').First(),
                        CreatedByUserId = adminId,
                        CreatedOn = date,
                        UpdatedByUserId = adminId,
                        UpdatedOn = date,
                        IsCurrentVersion = true,
                        PublishedByUserId = adminId,
                        PublishedOn = date,
                        From = from,
                        Subject = data.Subject,
                        Body = data.Body
                    };

                    source.Save(content);
                }
            }
        }