Beispiel #1
0
        public PRO_tblProvinceDRO DeleteProvince(string Username, string LanguageID, string ProvinceIDList)
        {
            PRO_tblProvinceDRO result = new PRO_tblProvinceDRO();
            try
            {
                using (var scope = Container.BeginLifetimeScope())
                {
                    string temp = "";
                    var db = scope.Resolve<IPRO_tblProvinceDAO>();
                    if (ProvinceIDList.Contains("$"))
                        temp = db.DeleteProvinceList(ProvinceIDList, Username, LanguageID);
                    else temp = db.DeleteProvince(ProvinceIDList, 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 province failed because: " + ex.Message,
                    RequestUser = Username,
                    TotalItemCount = 0
                };
                logger.Error(ex);
            }

            return result;
        }
Beispiel #2
0
        public PRO_tblProvinceDRO GetProvinceByID(string Username, string LanguageID, string ProvinceID)
        {
            PRO_tblProvinceDRO result = new PRO_tblProvinceDRO();
            try
            {
                using (var scope = Container.BeginLifetimeScope())
                {
                    var db = scope.Resolve<IPRO_tblProvinceDAO>();
                    var temp = db.GetDataByID(ProvinceID, Username, LanguageID);
                    if (temp != null)
                    {
                        result.ProvinceItem = Mapper.Map<PRO_tblProvinceDCO>(temp);
                        result.ResponseItem = new DCO.ResponseItem
                        {
                            Result = true,
                            Status = DCO.ResponseStatus.Success,
                            Message = "",
                            RequestUser = Username,
                            TotalItemCount = 1
                        };
                    }
                }
            }
            catch (Exception ex)
            {
                result.ProvinceItem = Mapper.Map<PRO_tblProvinceDCO>(new PRO_tblProvinceDTO());
                result.ResponseItem = new DCO.ResponseItem
                {
                    Result = false,
                    Status = DCO.ResponseStatus.Exception,
                    Message = "Load province item failed: " + ex.Message,
                    RequestUser = Username,
                    TotalItemCount = 0
                };
                logger.Error(ex);
            }

            return result;
        }
Beispiel #3
0
        public PRO_tblProvinceDRO InsertUpdateProvince(PRO_tblProvinceDCO province)
        {
            PRO_tblProvinceDRO result = new PRO_tblProvinceDRO();
            try
            {
                using (var scope = Container.BeginLifetimeScope())
                {
                    string temp = "";
                    var db = scope.Resolve<IPRO_tblProvinceDAO>();
                    var data = Mapper.Map<PRO_tblProvinceDTO>(province);
                    if (province.Activity.Equals(BaseConstant.COMMAND_INSERT_EN))
                        temp = db.InsertProvince(data);
                    else temp = db.UpdateProvince(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 = province.UserID,
                        TotalItemCount = string.IsNullOrEmpty(temp) ? 1 : 0
                    };
                }
            }
            catch (Exception ex)
            {
                result.ResponseItem = new DCO.ResponseItem
                {
                    Result = false,
                    Status = DCO.ResponseStatus.Exception,
                    Message = "Insert new province failed because: " + ex.Message,
                    RequestUser = province.UserID,
                    TotalItemCount = 0
                };
                logger.Error(ex);
            }

            return result;
        }
Beispiel #4
0
        public PRO_tblProvinceDRO GetAllProvinces(string Username, string LanguageID, bool GetCombobox)
        {
            PRO_tblProvinceDRO result = new PRO_tblProvinceDRO();
            try
            {
                using (var scope = Container.BeginLifetimeScope())
                {
                    List<PRO_tblProvinceDTO> temp = new List<PRO_tblProvinceDTO>();
                    var db = scope.Resolve<IPRO_tblProvinceDAO>();
                    if (!GetCombobox)
                        temp = db.LoadAllData(Username, LanguageID);
                    else temp = db.GetDataCombobox(Username, LanguageID);
                    if (temp != null)
                    {
                        result.ProvinceList = Mapper.Map<List<PRO_tblProvinceDCO>>(temp);
                        result.ResponseItem = new DCO.ResponseItem
                        {
                            Result = true,
                            Status = DCO.ResponseStatus.Success,
                            Message = "",
                            RequestUser = Username,
                            TotalItemCount = temp.Count
                        };
                    }
                }
            }
            catch (Exception ex)
            {
                result.ProvinceList = Mapper.Map<List<PRO_tblProvinceDCO>>(new List<PRO_tblProvinceDTO>());
                result.ResponseItem = new DCO.ResponseItem
                {
                    Result = false,
                    Status = DCO.ResponseStatus.Exception,
                    Message = "Load province list failed: " + ex.Message,
                    RequestUser = Username,
                    TotalItemCount = 0
                };
                logger.Error(ex);
            }

            return result;
        }