/// <summary>
        /// Gets all <see cref="GatewayProviderSettings"/>.
        /// </summary>
        /// <param name="keys">
        /// The keys.
        /// </param>
        /// <returns>
        /// The <see cref="IEnumerable{IGatewayProviderSettings}"/>.
        /// </returns>
        protected override IEnumerable <IGatewayProviderSettings> PerformGetAll(params Guid[] keys)
        {
            var dtos = new List <GatewayProviderSettingsDto>();

            if (keys.Any())
            {
                // This is to get around the WhereIn max limit of 2100 parameters and to help with performance of each WhereIn query
                var keyLists = keys.Split(400).ToList();

                // Loop the split keys and get them
                foreach (var keyList in keyLists)
                {
                    dtos.AddRange(Database.Fetch <GatewayProviderSettingsDto>(GetBaseQuery(false).WhereIn <GatewayProviderSettingsDto>(x => x.Key, keyList, SqlSyntax)));
                }
            }
            else
            {
                dtos = Database.Fetch <GatewayProviderSettingsDto>(GetBaseQuery(false));
            }

            var factory = new GatewayProviderSettingsFactory();

            foreach (var dto in dtos)
            {
                yield return(factory.BuildEntity(dto));
            }
        }
        protected override void PersistUpdatedItem(IGatewayProviderSettings entity)
        {
            ((Entity)entity).AddingEntity();

            var factory = new GatewayProviderSettingsFactory();
            var dto     = factory.BuildDto(entity);

            Database.Update(dto);

            entity.ResetDirtyProperties();
        }
        public IEnumerable <IGatewayProviderSettings> GetGatewayProvidersByShipCountryKey(Guid shipCountryKey)
        {
            var sql = new Sql();

            sql.Select("*")
            .From <ShipMethodDto>()
            .InnerJoin <GatewayProviderSettingsDto>()
            .On <ShipMethodDto, GatewayProviderSettingsDto>(left => left.ProviderKey, right => right.Key)
            .Where <ShipMethodDto>(x => x.ShipCountryKey == shipCountryKey);

            var dtos    = Database.Fetch <ShipMethodDto, GatewayProviderSettingsDto>(sql);
            var factory = new GatewayProviderSettingsFactory();

            return(dtos.DistinctBy(x => x.GatewayProviderSettingsDto.Key).Select(dto => factory.BuildEntity(dto.GatewayProviderSettingsDto)));
        }
        protected override IGatewayProviderSettings PerformGet(Guid key)
        {
            var sql = GetBaseQuery(false)
                      .Where(GetBaseWhereClause(), new { Key = key });

            var dto = Database.Fetch <GatewayProviderSettingsDto>(sql).FirstOrDefault();

            if (dto == null)
            {
                return(null);
            }

            var factory = new GatewayProviderSettingsFactory();

            return(factory.BuildEntity(dto));
        }
 protected override IEnumerable <IGatewayProviderSettings> PerformGetAll(params Guid[] keys)
 {
     if (keys.Any())
     {
         foreach (var key in keys)
         {
             yield return(Get(key));
         }
     }
     else
     {
         var factory = new GatewayProviderSettingsFactory();
         var dtos    = Database.Fetch <GatewayProviderSettingsDto>(GetBaseQuery(false));
         foreach (var dto in dtos)
         {
             yield return(factory.BuildEntity(dto));
         }
     }
 }