Пример #1
0
        /// <summary>
        /// Customs the fill.
        /// </summary>
        /// <param name="warehouse">The warehouse.</param>
        /// <param name="dataReader">The data reader.</param>
        /// <param name="fullyPopulate">if set to <c>true</c> [fully populate].</param>
        public static void CustomFill(Warehouse warehouse, IDataReader dataReader, bool fullyPopulate)
        {
            if (warehouse != null)
            {
                if (fullyPopulate)
                {
                    if (allRegions != null && allRegions.Count > 0)
                    {
                        warehouse.OptrakRegion =
                            allRegions.Find(delegate(OptrakRegion obj) { return(obj.Id == warehouse.RegionId); });
                    }
                    else
                    {
                        warehouse.OptrakRegion = OptrakRegionController.GetRegion(warehouse.RegionId);
                    }
                }

                //contact
                warehouse.Contact                 = new Contact();
                warehouse.Contact.Name            = dataReader["ContactName"].ToString();
                warehouse.Contact.TelephoneNumber = dataReader["ContactTelephone"].ToString();
                warehouse.Contact.Email           = dataReader["SalesEmail"].ToString();
                //address
                warehouse.Address          = new Address();
                warehouse.Address.Line1    = dataReader["AddressLine1"].ToString();
                warehouse.Address.Line2    = dataReader["AddressLine2"].ToString();
                warehouse.Address.Line3    = dataReader["AddressLine3"].ToString();
                warehouse.Address.Line4    = dataReader["AddressLine4"].ToString();
                warehouse.Address.PostCode = dataReader["PostCode"].ToString();
            }
        }
Пример #2
0
        /// <summary>
        /// Gets the warehouses.
        /// </summary>
        /// <param name="fullyPopualte">if set to <c>true</c> [fully popualte].</param>
        /// <returns></returns>
        public static List <Warehouse> GetWarehouses(bool fullyPopualte)
        {
            List <Warehouse> warehouses = new List <Warehouse>();

            try
            {
                if (fullyPopualte)
                {
                    allRegions = OptrakRegionController.GetRegions();
                }
                warehouses = CBO <Warehouse> .FillCollection(DataAccessProvider.Instance().GetWarehouses(), CustomFill, fullyPopualte);

                allRegions = null;
            }
            catch (Exception ex)
            {
                if (ExceptionPolicy.HandleException(ex, "Business Logic"))
                {
                    throw;
                }
            }

            if (warehouses != null)
            {
                foreach (Warehouse warehouse in warehouses)
                {
                    CacheManager.Add(warehouse, fullyPopualte);
                }
            }
            return(warehouses);
        }