Пример #1
0
        public PRO_tblProductGroupLevel1DRO DeleteLevel1(string Username, string LanguageID, string Level1IDList)
        {
            PRO_tblProductGroupLevel1DRO result = new PRO_tblProductGroupLevel1DRO();
            try
            {
                using (var scope = Container.BeginLifetimeScope())
                {
                    string temp = "";
                    var db = scope.Resolve<IPRO_tblProductGroupLevel1DAO>();
                    if (Level1IDList.Contains("$"))
                        temp = db.DeleteLevel1List(Username, LanguageID, Level1IDList);
                    else temp = db.DeleteLevel1(Username, LanguageID, Level1IDList);

                    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 level1 failed because: " + ex.Message,
                    RequestUser = Username,
                    TotalItemCount = 0
                };
                logger.Error(ex);
            }

            return result;
        }
Пример #2
0
        public PRO_tblProductGroupLevel1DRO GetLevel1ByID(string Username, string LanguageID, string Level1ID)
        {
            PRO_tblProductGroupLevel1DRO result = new PRO_tblProductGroupLevel1DRO();
            try
            {
                using (var scope = Container.BeginLifetimeScope())
                {
                    var db = scope.Resolve<IPRO_tblProductGroupLevel1DAO>();
                    var temp = db.GetDataByID(Username, LanguageID, Level1ID);
                    if (temp != null)
                    {
                        result.Level1Item = Mapper.Map<PRO_tblProductGroupLevel1DCO>(temp);
                        result.ResponseItem = new DCO.ResponseItem
                        {
                            Result = true,
                            Status = DCO.ResponseStatus.Success,
                            Message = "",
                            RequestUser = Username,
                            TotalItemCount = 1
                        };
                    }
                }
            }
            catch (Exception ex)
            {
                result.Level1Item = Mapper.Map<PRO_tblProductGroupLevel1DCO>(new PRO_tblProductGroupLevel1DTO());
                result.ResponseItem = new DCO.ResponseItem
                {
                    Result = false,
                    Status = DCO.ResponseStatus.Exception,
                    Message = "Load level1 item failed: " + ex.Message,
                    RequestUser = Username,
                    TotalItemCount = 0
                };
                logger.Error(ex);
            }

            return result;
        }
Пример #3
0
        public PRO_tblProductGroupLevel1DRO InsertUpdateLevel1(PRO_tblProductGroupLevel1DCO level1)
        {
            PRO_tblProductGroupLevel1DRO result = new PRO_tblProductGroupLevel1DRO();
            try
            {
                using (var scope = Container.BeginLifetimeScope())
                {
                    string temp = "";
                    var db = scope.Resolve<IPRO_tblProductGroupLevel1DAO>();
                    var data = Mapper.Map<PRO_tblProductGroupLevel1DTO>(level1);
                    if (level1.Activity.Equals(BaseConstant.COMMAND_INSERT_EN))
                        temp = db.InsertLevel1(data);
                    else temp = db.UpdateLevel1(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 = level1.UserID,
                        TotalItemCount = string.IsNullOrEmpty(temp) ? 1 : 0
                    };
                }
            }
            catch (Exception ex)
            {
                result.ResponseItem = new DCO.ResponseItem
                {
                    Result = false,
                    Status = DCO.ResponseStatus.Exception,
                    Message = "Insert new level1 failed because: " + ex.Message,
                    RequestUser = level1.UserID,
                    TotalItemCount = 0
                };
                logger.Error(ex);
            }

            return result;
        }
Пример #4
0
        public PRO_tblProductGroupLevel1DRO GetAllLevel1(string Username, string LanguageID, bool GetCombobox)
        {
            PRO_tblProductGroupLevel1DRO result = new PRO_tblProductGroupLevel1DRO();
            try
            {
                using (var scope = Container.BeginLifetimeScope())
                {
                    List<PRO_tblProductGroupLevel1DTO> temp = new List<PRO_tblProductGroupLevel1DTO>();
                    var db = scope.Resolve<IPRO_tblProductGroupLevel1DAO>();
                    if (!GetCombobox)
                        temp = db.LoadAllData(Username, LanguageID);
                    else temp = db.GetDataCombobox(Username, LanguageID);
                    if (temp != null)
                    {
                        result.Level1List = Mapper.Map<List<PRO_tblProductGroupLevel1DCO>>(temp);
                        result.ResponseItem = new DCO.ResponseItem
                        {
                            Result = true,
                            Status = DCO.ResponseStatus.Success,
                            Message = "",
                            RequestUser = Username,
                            TotalItemCount = temp.Count
                        };
                    }
                }
            }
            catch (Exception ex)
            {
                result.Level1List = Mapper.Map<List<PRO_tblProductGroupLevel1DCO>>(new List<PRO_tblProductGroupLevel1DTO>());
                result.ResponseItem = new DCO.ResponseItem
                {
                    Result = false,
                    Status = DCO.ResponseStatus.Exception,
                    Message = "Load level1 list failed: " + ex.Message,
                    RequestUser = Username,
                    TotalItemCount = 0
                };
                logger.Error(ex);
            }

            return result;
        }