protected EmployeeModuleSettings Seed(CreateEmployeeModuleSettings command)
        {
            // make sure entity does not already exist
            var employeeModuleSettings = _queryProcessor.Execute(
                new EmployeeModuleSettingsByEstablishmentId(command.EstablishmentId, true));

            if (employeeModuleSettings != null)
            {
                return(employeeModuleSettings);
            }

            var iconsBinaryPath = string.Format("{0}/{1}/", EmployeeConsts.SettingsBinaryStoreBasePath,
                                                EmployeeConsts.IconsBinaryStorePath);

            foreach (var icon in UsfEmployeeModuleSettingsSeeder.UsfEmployeeModuleSettingIcons)
            {
                var iconPath = Path.Combine(iconsBinaryPath, icon.Value.Third.ToString());
                if (!_binaryStore.Exists(iconPath))
                {
                    var filePath = string.Format("{0}{1}{2}", AppDomain.CurrentDomain.BaseDirectory,
                                                 @"..\UCosmic.Infrastructure\SeedData\SeedMediaFiles\",
                                                 icon.Key);

                    using (var fileStream = File.OpenRead(filePath))
                        _binaryStore.Put(iconPath, fileStream.ReadFully());
                }

                if (string.IsNullOrEmpty(command.GlobalViewIconPath) && icon.Value.First == "Global")
                {
                    command.GlobalViewIconFileName = icon.Value.Third.ToString();
                    command.GlobalViewIconLength   = _binaryStore.Get(iconPath).Length;
                    command.GlobalViewIconMimeType = "image/png";
                    command.GlobalViewIconName     = icon.Value.Second;
                    command.GlobalViewIconPath     = iconsBinaryPath;
                }

                if (string.IsNullOrEmpty(command.FindAnExpertIconPath) && icon.Value.First == "Expert")
                {
                    command.FindAnExpertIconFileName = icon.Value.Third.ToString();
                    command.FindAnExpertIconLength   = _binaryStore.Get(iconPath).Length;
                    command.FindAnExpertIconMimeType = "image/svg+xml";
                    command.FindAnExpertIconName     = icon.Value.Second;
                    command.FindAnExpertIconPath     = iconsBinaryPath;
                }
            }

            _createEmployeeModuleSettings.Handle(command);

            _unitOfWork.SaveChanges();

            return(command.CreatedEmployeeModuleSettings);
        }
        protected EmployeeModuleSettings Seed(CreateEmployeeModuleSettings command)
        {
            // make sure entity does not already exist
            var employeeModuleSettings = _queryProcessor.Execute(
                new EmployeeModuleSettingsByEstablishmentId(command.EstablishmentId));

            if (employeeModuleSettings != null) return employeeModuleSettings;

            _createEmployeeModuleSettings.Handle(command);

            _unitOfWork.SaveChanges();

            return command.CreatedEmployeeModuleSettings;
        }