Exemplo n.º 1
0
        /// <summary>
        /// Gets the collection of all <see cref="IWarehouse"/>.
        /// </summary>
        /// <param name="keys">
        /// The keys.
        /// </param>
        /// <returns>
        /// The <see cref="IEnumerable{IWarehouse}"/>.
        /// </returns>
        protected override IEnumerable <IWarehouse> PerformGetAll(params Guid[] keys)
        {
            var dtos = new List <WarehouseDto>();

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

            var factory = new WarehouseFactory();

            foreach (var dto in dtos)
            {
                yield return(factory.BuildEntity(dto, _warehouseCatalogRepository.GetWarehouseCatalogsByWarehouseKey(dto.Key)));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Updates an existing item in the database.
        /// </summary>
        /// <param name="entity">
        /// The entity.
        /// </param>
        protected override void PersistUpdatedItem(IWarehouse entity)
        {
            ((Entity)entity).UpdatingEntity();

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

            Database.Update(dto);

            entity.ResetDirtyProperties();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Saves a new item to the database.
        /// </summary>
        /// <param name="entity">
        /// The entity.
        /// </param>
        protected override void PersistNewItem(IWarehouse entity)
        {
            ((Entity)entity).AddingEntity();

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

            Database.Insert(dto);
            entity.Key = dto.Key;

            // TODO : warehouses will need to have a default WarehouseCatalog

            entity.ResetDirtyProperties();
        }
Exemplo n.º 4
0
 /// <summary>
 /// Gets the collection of all <see cref="IWarehouse"/>.
 /// </summary>
 /// <param name="keys">
 /// The keys.
 /// </param>
 /// <returns>
 /// The <see cref="IEnumerable{IWarehouse}"/>.
 /// </returns>
 protected override IEnumerable <IWarehouse> PerformGetAll(params Guid[] keys)
 {
     if (keys.Any())
     {
         foreach (var key in keys)
         {
             yield return(Get(key));
         }
     }
     else
     {
         var factory = new WarehouseFactory();
         var dtos    = Database.Fetch <WarehouseDto>(GetBaseQuery(false));
         foreach (var dto in dtos)
         {
             yield return(factory.BuildEntity(dto, _warehouseCatalogRepository.GetWarehouseCatalogsByWarehouseKey(dto.Key)));
         }
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Gets a <see cref="IWarehouse"/> by it's key.
        /// </summary>
        /// <param name="key">
        /// The key.
        /// </param>
        /// <returns>
        /// The <see cref="IWarehouse"/>.
        /// </returns>
        protected override IWarehouse PerformGet(Guid key)
        {
            var sql = GetBaseQuery(false)
                      .Where(GetBaseWhereClause(), new { Key = key });

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

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

            var factory = new WarehouseFactory();

            var warehouse = factory.BuildEntity(dto, _warehouseCatalogRepository.GetWarehouseCatalogsByWarehouseKey(key));


            return(warehouse);
        }