Пример #1
0
        public PRO_tblDistrictDRO DeleteDistrict(string Username, string LanguageID, string DistrictIDList)
        {
            PRO_tblDistrictDRO result = new PRO_tblDistrictDRO();
            try
            {
                using (var scope = Container.BeginLifetimeScope())
                {
                    string temp = "";
                    var db = scope.Resolve<IPRO_tblDistrictDAO>();
                    if (DistrictIDList.Contains("$"))
                        temp = db.DeleteDistrictList(DistrictIDList, Username, LanguageID);
                    else temp = db.DeleteDistrict(DistrictIDList, 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 district failed because: " + ex.Message,
                    RequestUser = Username,
                    TotalItemCount = 0
                };
                logger.Error(ex);
            }

            return result;
        }
Пример #2
0
        public PRO_tblDistrictDRO GetDistrictByID(string Username, string LanguageID, string DistrictID)
        {
            PRO_tblDistrictDRO result = new PRO_tblDistrictDRO();
            try
            {
                using (var scope = Container.BeginLifetimeScope())
                {
                    var db = scope.Resolve<IPRO_tblDistrictDAO>();
                    var temp = db.GetDataByID(DistrictID, Username, LanguageID);
                    if (temp != null)
                    {
                        result.DistrictItem = Mapper.Map<PRO_tblDistrictDCO>(temp);
                        result.ResponseItem = new DCO.ResponseItem
                        {
                            Result = true,
                            Status = DCO.ResponseStatus.Success,
                            Message = "",
                            RequestUser = Username,
                            TotalItemCount = 1
                        };
                    }
                }
            }
            catch (Exception ex)
            {
                result.DistrictItem = Mapper.Map<PRO_tblDistrictDCO>(new PRO_tblDistrictDTO());
                result.ResponseItem = new DCO.ResponseItem
                {
                    Result = false,
                    Status = DCO.ResponseStatus.Exception,
                    Message = "Load district item failed: " + ex.Message,
                    RequestUser = Username,
                    TotalItemCount = 0
                };
                logger.Error(ex);
            }

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

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

            return result;
        }