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

            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 <StoreSettingDto>(GetBaseQuery(false).WhereIn <StoreSettingDto>(x => x.Key, keyList, SqlSyntax)));
                }
            }
            else
            {
                dtos = Database.Fetch <StoreSettingDto>(GetBaseQuery(false));
            }

            var factory = new StoreSettingFactory();

            foreach (var dto in dtos)
            {
                yield return(factory.BuildEntity(dto));
            }
        }
        /// <summary>
        /// Persist an updated <see cref="IStoreSetting"/>.
        /// </summary>
        /// <param name="entity">
        /// The entity.
        /// </param>
        protected override void PersistUpdatedItem(IStoreSetting entity)
        {
            ((Entity)entity).UpdatingEntity();

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

            Database.Update(dto);

            entity.ResetDirtyProperties();
        }
        /// <summary>
        /// Persists a new <see cref="IStoreSetting"/>.
        /// </summary>
        /// <param name="entity">
        /// The entity.
        /// </param>
        protected override void PersistNewItem(IStoreSetting entity)
        {
            ((Entity)entity).AddingEntity();

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

            Database.Insert(dto);

            entity.Key = dto.Key;

            entity.ResetDirtyProperties();
        }
Пример #4
0
 public IngStoreSettingsController()
 {
     _storeFactory   = new StoreFactory();
     _factory        = new StoreSettingFactory();
     _factoryCompany = new CompanyFactory();
     //================
     if (CurrentUser != null)
     {
         listOrganization = CurrentUser.ListOrganizationId;
     }
     lstCompany    = _factoryCompany.GetListCompany(listOrganization);
     listCompanyId = lstCompany.Select(x => x.Value).ToList();
     lstStore      = _storeFactory.GetListStore(listOrganization);
 }
        /// <summary>
        /// Gets a <see cref="IStoreSetting"/> by it's key
        /// </summary>
        /// <param name="key">
        /// The key.
        /// </param>
        /// <returns>
        /// The <see cref="IStoreSetting"/>.
        /// </returns>
        protected override IStoreSetting PerformGet(Guid key)
        {
            var sql = GetBaseQuery(false)
                      .Where(GetBaseWhereClause(), new { Key = key });

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

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

            var factory = new StoreSettingFactory();

            var setting = factory.BuildEntity(dto);

            return(setting);
        }
 /// <summary>
 /// Gets a collection of all <see cref="IStoreSetting"/>
 /// </summary>
 /// <param name="keys">
 /// The keys.
 /// </param>
 /// <returns>
 /// The <see cref="IEnumerable{IStoreSetting}"/>.
 /// </returns>
 protected override IEnumerable <IStoreSetting> PerformGetAll(params Guid[] keys)
 {
     if (keys.Any())
     {
         foreach (var id in keys)
         {
             yield return(Get(id));
         }
     }
     else
     {
         var factory = new StoreSettingFactory();
         var dtos    = Database.Fetch <StoreSettingDto>(GetBaseQuery(false));
         foreach (var dto in dtos)
         {
             yield return(factory.BuildEntity(dto));
         }
     }
 }