public PRO_tblProductGroupLevel2DRO DeleteLevel2(string Username, string LanguageID, string Level2IDList) { PRO_tblProductGroupLevel2DRO result = new PRO_tblProductGroupLevel2DRO(); try { using (var scope = Container.BeginLifetimeScope()) { string temp = ""; var db = scope.Resolve<IPRO_tblProductGroupLevel2DAO>(); if (Level2IDList.Contains("$")) temp = db.DeleteLevel2List(Username, LanguageID, Level2IDList); else temp = db.DeleteLevel2(Username, LanguageID, Level2IDList); 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 level2 failed because: " + ex.Message, RequestUser = Username, TotalItemCount = 0 }; logger.Error(ex); } return result; }
public PRO_tblProductGroupLevel2DRO GetLevel2ByID(string Username, string LanguageID, string Level2ID) { PRO_tblProductGroupLevel2DRO result = new PRO_tblProductGroupLevel2DRO(); try { using (var scope = Container.BeginLifetimeScope()) { var db = scope.Resolve<IPRO_tblProductGroupLevel2DAO>(); var temp = db.GetDataByID(Username, LanguageID, Level2ID); if (temp != null) { result.Level2Item = Mapper.Map<PRO_tblProductGroupLevel2DCO>(temp); result.ResponseItem = new DCO.ResponseItem { Result = true, Status = DCO.ResponseStatus.Success, Message = "", RequestUser = Username, TotalItemCount = 1 }; } } } catch (Exception ex) { result.Level2Item = Mapper.Map<PRO_tblProductGroupLevel2DCO>(new PRO_tblProductGroupLevel2DTO()); result.ResponseItem = new DCO.ResponseItem { Result = false, Status = DCO.ResponseStatus.Exception, Message = "Load level2 item failed: " + ex.Message, RequestUser = Username, TotalItemCount = 0 }; logger.Error(ex); } return result; }
public PRO_tblProductGroupLevel2DRO InsertUpdateLevel2(PRO_tblProductGroupLevel2DCO level2) { PRO_tblProductGroupLevel2DRO result = new PRO_tblProductGroupLevel2DRO(); try { using (var scope = Container.BeginLifetimeScope()) { string temp = ""; var db = scope.Resolve<IPRO_tblProductGroupLevel2DAO>(); var data = Mapper.Map<PRO_tblProductGroupLevel2DTO>(level2); if (level2.Activity.Equals(BaseConstant.COMMAND_INSERT_EN)) temp = db.InsertLevel2(data); else temp = db.UpdateLevel2(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 = level2.UserID, TotalItemCount = string.IsNullOrEmpty(temp) ? 1 : 0 }; } } catch (Exception ex) { result.ResponseItem = new DCO.ResponseItem { Result = false, Status = DCO.ResponseStatus.Exception, Message = "Insert new level2 failed because: " + ex.Message, RequestUser = level2.UserID, TotalItemCount = 0 }; logger.Error(ex); } return result; }
public PRO_tblProductGroupLevel2DRO GetAllLevel2(string Username, string LanguageID, string Level1ID, bool GetCombobox) { PRO_tblProductGroupLevel2DRO result = new PRO_tblProductGroupLevel2DRO(); try { using (var scope = Container.BeginLifetimeScope()) { List<PRO_tblProductGroupLevel2DTO> temp = new List<PRO_tblProductGroupLevel2DTO>(); var db = scope.Resolve<IPRO_tblProductGroupLevel2DAO>(); if (!GetCombobox) temp = db.LoadAllData(Username, LanguageID, Level1ID); else temp = db.GetDataCombobox(Username, LanguageID, Level1ID); if (temp != null) { result.Level2List = Mapper.Map<List<PRO_tblProductGroupLevel2DCO>>(temp); result.ResponseItem = new DCO.ResponseItem { Result = true, Status = DCO.ResponseStatus.Success, Message = "", RequestUser = Username, TotalItemCount = temp.Count }; } } } catch (Exception ex) { result.Level2List = Mapper.Map<List<PRO_tblProductGroupLevel2DCO>>(new List<PRO_tblProductGroupLevel2DTO>()); result.ResponseItem = new DCO.ResponseItem { Result = false, Status = DCO.ResponseStatus.Exception, Message = "Load level2 list failed: " + ex.Message, RequestUser = Username, TotalItemCount = 0 }; logger.Error(ex); } return result; }