コード例 #1
0
        //Given a name, fetch Warehouse from Warehouses table
        //Returns a Warehouse_BDO object
        public Warehouse_BDO Get_Warehouse_By_Name(string warehouse_Name)
        {
            //Create Warehouse_BDO object
            Warehouse_BDO warehouse_BDO = new Warehouse_BDO();

            //Create new DTO for Warehouse query result
            DataModel.Warehouse warehouse_DTO_Result = new DataModel.Warehouse();

            //Call Warehouse_Qs.Get_Warehouse_By_Name
            Warehouse_Qs warehouse_Query = new Warehouse_Qs();

            warehouse_DTO_Result = warehouse_Query.Get_Warehouse_By_Name(warehouse_Name);

            //If Warehouse is found, tranlsate to BDO object
            if (warehouse_DTO_Result.Warehouse_Name != null && warehouse_DTO_Result.Street != null &&
                warehouse_DTO_Result.City != null && warehouse_DTO_Result.State != null && warehouse_DTO_Result.Zipcode != null)
            {
                warehouse_BDO.Warehouse_ID   = warehouse_DTO_Result.Warehouse_ID;
                warehouse_BDO.Warehouse_Name = warehouse_DTO_Result.Warehouse_Name;
                warehouse_BDO.Street         = warehouse_DTO_Result.Street;
                warehouse_BDO.City           = warehouse_DTO_Result.City;
                warehouse_BDO.State          = warehouse_DTO_Result.State;
                warehouse_BDO.Zipcode        = warehouse_DTO_Result.Zipcode;
            }

            return(warehouse_BDO);
        }
コード例 #2
0
        //Return list of Warehouses in a database
        public List <Warehouse_BDO> GetWarehouses()
        {
            List <Warehouse_BDO> Warehouse_List = new List <Warehouse_BDO>();

            List <DataModel.Warehouse> warehouses_DTO_result = new List <DataModel.Warehouse>();

            Warehouse_Qs warehouse_query = new Warehouse_Qs();

            warehouses_DTO_result = warehouse_query.Get_All_Warehouses();

            if (warehouses_DTO_result != null)
            {
                foreach (DataModel.Warehouse w in warehouses_DTO_result)
                {
                    Warehouse_BDO warehouse_BDO_ = new Warehouse_BDO();
                    // Translate Data Model Object to Business Domain Object.
                    Translate_DMO_to_BDO(w, warehouse_BDO_);

                    Warehouse_List.Add(warehouse_BDO_);
                }
                return(Warehouse_List);
            }

            return(Warehouse_List);
        }
 private void TranslateWarehouseDTOToWarehouseBDO(Warehouse warehouse, Warehouse_BDO warehouse_BDO)
 {
     warehouse_BDO.Warehouse_ID   = warehouse.WarehouseID;
     warehouse_BDO.Warehouse_Name = warehouse.WarehouseName;
     warehouse_BDO.Street         = warehouse.WarehouseAddressStreet;
     warehouse_BDO.City           = warehouse.WarehouseAddressCity;
     warehouse_BDO.State          = warehouse.WarehouseAddressState;
     warehouse_BDO.Zipcode        = warehouse.WarehouseAddressZipcode;
 }
コード例 #4
0
 private void Translate_DMO_to_BDO(DataModel.Warehouse warehouse_dmo, Warehouse_BDO warehouse_bdo)
 {
     warehouse_bdo.Warehouse_ID   = warehouse_dmo.Warehouse_ID;
     warehouse_bdo.Warehouse_Name = warehouse_dmo.Warehouse_Name;
     warehouse_bdo.Street         = warehouse_dmo.Street;
     warehouse_bdo.City           = warehouse_dmo.City;
     warehouse_bdo.State          = warehouse_dmo.State;
     warehouse_bdo.Zipcode        = warehouse_dmo.Zipcode;
 }
        //Given a Warehouse_BDO, returns true/false depending on the success of the create
        public bool Create_Warehouse(ref Warehouse_BDO warehouse_BDO, ref string message)
        {
            var warehouse = Get_Warehouse_By_Name(warehouse_BDO.Warehouse_Name);

            if (warehouse.Warehouse_Name != null && warehouse.Street != null && warehouse.City != null && warehouse.State != null && warehouse.Zipcode != null)
            {
                message = "Warehouse exists already!";
                return(false);
            }
            else
            {
                return(warehouse_DAO.Create_Warehouse(ref warehouse_BDO, ref message));
            }
        }
        //Given a Warehouse_BDO, returns true/false depending on the success of the update
        public bool Update_Warehouse(ref Warehouse_BDO warehouse_BDO, ref string message)
        {
            var warehouse = Get_Warehouse_By_ID(warehouse_BDO.Warehouse_ID);

            if (warehouse == null)
            {
                message = "Warehouse not in database";
                return(false);
            }
            else
            {
                message = "Warehouse updated";
                return(warehouse_DAO.Update_Warehouse(ref warehouse_BDO, ref message));
            }
        }
        public bool CreateWarehouse(Warehouse warehouse, ref string message)
        {
            var result = true;

            //Warehouse name cannot be empty
            if (string.IsNullOrEmpty(warehouse.WarehouseName))
            {
                message = "Warehouse name cannot be empty";
                result  = false;
            }
            else if (string.IsNullOrEmpty(warehouse.WarehouseAddressCity))
            {
                message = "Warehouse city cannot be empty";
                result  = false;
            }
            else if (string.IsNullOrEmpty(warehouse.WarehouseAddressState))
            {
                message = "Warehouse state cannot be empty";
                result  = false;
            }
            else if (string.IsNullOrEmpty(warehouse.WarehouseAddressStreet))
            {
                message = "Warehouse street cannot be empty";
                result  = false;
            }
            else if (string.IsNullOrEmpty(warehouse.WarehouseAddressZipcode))
            {
                message = "Warehouse zip code cannot be empty";
                result  = false;
            }
            else
            {
                try
                {
                    var warehouseBDO = new Warehouse_BDO();
                    TranslateWarehouseDTOToWarehouseBDO(warehouse, warehouseBDO);
                    result = warehouse_Logic.Create_Warehouse(ref warehouseBDO, ref message);
                }
                catch (Exception e)
                {
                    throw new InvalidOperationException("Unable to create warehouse", e);
                }
            }

            return(result);
        }
        public bool UpdateWarehouse(Warehouse warehouse, ref string message)
        {
            var result = true;

            // Warehouse name cannot be empty
            if (string.IsNullOrEmpty(warehouse.WarehouseName))
            {
                message = "Warehouse name cannot be empty";
                result  = false;
            }
            else if (string.IsNullOrEmpty(warehouse.WarehouseAddressStreet))
            {
                message = "Warehouse street address cannot be empty";
                result  = false;
            }

            else if (string.IsNullOrEmpty(warehouse.WarehouseAddressCity))
            {
                message = "Warehouse city address cannot be empty";
                result  = false;
            }

            else if (string.IsNullOrEmpty(warehouse.WarehouseAddressState))
            {
                message = "Warehouse state address cannot be empty";
                result  = false;
            }

            else if (string.IsNullOrEmpty(warehouse.WarehouseAddressZipcode))
            {
                message = "Warehouse Zipcode cannot be empty";
                result  = false;
            }

            else
            {
                var warehouse_BDO = new Warehouse_BDO();
                TranslateWarehouseDTOToWarehouseBDO(warehouse, warehouse_BDO);
                return(warehouse_Logic.Update_Warehouse(ref warehouse_BDO, ref message));
            }

            return(result);
        }
コード例 #9
0
        //Given a Warehouse_BDO object, add to Warehouses table
        //Returns a boolean
        public bool Create_Warehouse(ref Warehouse_BDO warehouse_BDO, ref string message)
        {
            var ret = false;

            //Create new DTO object for Warehouse query
            DataModel.Warehouse warehouse_DTO = new DataModel.Warehouse();

            //Translate BDO to DTO for Warehouse_Qs
            warehouse_DTO.Warehouse_Name = warehouse_BDO.Warehouse_Name;
            warehouse_DTO.Street         = warehouse_BDO.Street;
            warehouse_DTO.City           = warehouse_BDO.City;
            warehouse_DTO.State          = warehouse_BDO.State;
            warehouse_DTO.Zipcode        = warehouse_BDO.Zipcode;

            //Call Warehouse_Qs.Create
            Warehouse_Qs warehouse_Create_Query = new Warehouse_Qs();

            ret = warehouse_Create_Query.Create(warehouse_DTO, ref message);

            return(ret);
        }