Exemple #1
0
        public PRO_tblWarehouseDRO DeleteWarehouse(string Username, string LanguageID, string WarehouseIDList)
        {
            PRO_tblWarehouseDRO result = new PRO_tblWarehouseDRO();
            try
            {
                using (var scope = Container.BeginLifetimeScope())
                {
                    string temp = "";
                    var db = scope.Resolve<IPRO_tblWarehouseDAO>();
                    if (WarehouseIDList.Contains("$"))
                        temp = db.DeleteWarehouseList(WarehouseIDList, Username, LanguageID);
                    else temp = db.DeleteWarehouse(WarehouseIDList, Username, LanguageID);

                    result.ResponseItem = new DCO.ResponseItem
                    {
                        Result = string.IsNullOrEmpty(temp) ? true : false,
                        Status = string.IsNullOrEmpty(temp) ? DCO.ResponseStatus.Success : DCO.ResponseStatus.Failure,
                        Message = string.IsNullOrEmpty(temp) ? string.Empty : temp,
                        RequestUser = Username,
                        TotalItemCount = string.IsNullOrEmpty(temp) ? 1 : 0
                    };
                }
            }
            catch (Exception ex)
            {
                result.ResponseItem = new DCO.ResponseItem
                {
                    Result = false,
                    Status = DCO.ResponseStatus.Exception,
                    Message = "Delete warehouse failed because: " + ex.Message,
                    RequestUser = Username,
                    TotalItemCount = 0
                };
                logger.Error(ex);
            }

            return result;
        }
Exemple #2
0
        public PRO_tblWarehouseDRO GetWarehouseByID(string Username, string LanguageID, string WarehouseID)
        {
            PRO_tblWarehouseDRO result = new PRO_tblWarehouseDRO();
            try
            {
                using (var scope = Container.BeginLifetimeScope())
                {
                    var db = scope.Resolve<IPRO_tblWarehouseDAO>();
                    var temp = db.GetDataByID(Username, LanguageID, WarehouseID);
                    if (temp != null)
                    {
                        result.WarehouseItem = Mapper.Map<PRO_tblWarehouseDCO>(temp);
                        result.ResponseItem = new DCO.ResponseItem
                        {
                            Result = true,
                            Status = DCO.ResponseStatus.Success,
                            Message = "",
                            RequestUser = Username,
                            TotalItemCount = 1
                        };
                    }
                }
            }
            catch (Exception ex)
            {
                result.WarehouseItem = Mapper.Map<PRO_tblWarehouseDCO>(new PRO_tblWarehouseDTO());
                result.ResponseItem = new DCO.ResponseItem
                {
                    Result = false,
                    Status = DCO.ResponseStatus.Exception,
                    Message = "Load warehouse item failed: " + ex.Message,
                    RequestUser = Username,
                    TotalItemCount = 0
                };
                logger.Error(ex);
            }

            return result;
        }
Exemple #3
0
        public PRO_tblWarehouseDRO InsertUpdateWarehouse(PRO_tblWarehouseDCO warehouse)
        {
            PRO_tblWarehouseDRO result = new PRO_tblWarehouseDRO();
            try
            {
                using (var scope = Container.BeginLifetimeScope())
                {
                    string temp = "";
                    var db = scope.Resolve<IPRO_tblWarehouseDAO>();
                    var data = Mapper.Map<PRO_tblWarehouseDTO>(warehouse);
                    if (warehouse.Activity.Equals(BaseConstant.COMMAND_INSERT_EN))
                        temp = db.InsertWarehouse(data);
                    else temp = db.UpdateWarehouse(data);

                    result.ResponseItem = new DCO.ResponseItem
                    {
                        Result = string.IsNullOrEmpty(temp) ? true : false,
                        Status = string.IsNullOrEmpty(temp) ? DCO.ResponseStatus.Success : DCO.ResponseStatus.Failure,
                        Message = string.IsNullOrEmpty(temp) ? string.Empty : temp,
                        RequestUser = warehouse.UserID,
                        TotalItemCount = string.IsNullOrEmpty(temp) ? 1 : 0
                    };
                }
            }
            catch (Exception ex)
            {
                result.ResponseItem = new DCO.ResponseItem
                {
                    Result = false,
                    Status = DCO.ResponseStatus.Exception,
                    Message = "Insert new warehouse failed because: " + ex.Message,
                    RequestUser = warehouse.UserID,
                    TotalItemCount = 0
                };
                logger.Error(ex);
            }

            return result;
        }
Exemple #4
0
        public PRO_tblWarehouseDRO GetAllWarehouses(string Username, string LanguageID, string StoreID, string ProvinceID, string DistrictID, bool GetCombobox)
        {
            PRO_tblWarehouseDRO result = new PRO_tblWarehouseDRO();
            try
            {
                using (var scope = Container.BeginLifetimeScope())
                {
                    List<PRO_tblWarehouseDTO> temp = new List<PRO_tblWarehouseDTO>();
                    var db = scope.Resolve<IPRO_tblWarehouseDAO>();
                    if (!GetCombobox)
                        temp = db.LoadAllData(Username, LanguageID, StoreID, ProvinceID, DistrictID);
                    else temp = db.GetDataCombobox(Username, LanguageID, StoreID);
                    if (temp != null)
                    {
                        result.WarehouseList = Mapper.Map<List<PRO_tblWarehouseDCO>>(temp);
                        result.ResponseItem = new DCO.ResponseItem
                        {
                            Result = true,
                            Status = DCO.ResponseStatus.Success,
                            Message = "",
                            RequestUser = Username,
                            TotalItemCount = temp.Count
                        };
                    }
                }
            }
            catch (Exception ex)
            {
                result.WarehouseList = Mapper.Map<List<PRO_tblWarehouseDCO>>(new List<PRO_tblWarehouseDTO>());
                result.ResponseItem = new DCO.ResponseItem
                {
                    Result = false,
                    Status = DCO.ResponseStatus.Exception,
                    Message = "Load warehouse list failed: " + ex.Message,
                    RequestUser = Username,
                    TotalItemCount = 0
                };
                logger.Error(ex);
            }

            return result;
        }