public NippsModuleResponse List(NippsModuleRequest nippsModuleRequest) { //this operation returns only parent modules, not childs. NippsModuleResponse response = new NippsModuleResponse(); response.ResultMessages = new List<string>(); if (nippsModuleRequest == null) nippsModuleRequest = new NippsModuleRequest { PageNo = 1, PageSize = 1000, NippsModules = new List<NippsModule> { new NippsModule { ParentId = 0 } } }; if (nippsModuleRequest.PageNo < 1) nippsModuleRequest.PageNo = 1; if (nippsModuleRequest.PageSize == 0) nippsModuleRequest.PageSize = 1000; if (nippsModuleRequest.NippsModules == null || nippsModuleRequest.NippsModules.Count == 0) nippsModuleRequest.NippsModules = new List<NippsModule> { new NippsModule { ParentId = 0 } }; try { using (ILifetimeScope scope = NippsIoCHelper.IoCContainer.BeginLifetimeScope()) { IGenericLogicV2<NippsModule> logModuleLogic = scope.Resolve<IGenericLogicV2<NippsModule>>(); logModuleLogic.PageSize = nippsModuleRequest.PageSize; try { response.NippsModules = logModuleLogic.List(nippsModuleRequest.NippsModules[0], nippsModuleRequest.PageNo); response.Result = Result.OK; } catch (NoDataFoundException ex) { response.Result = Result.FAIL; response.ResultMessages.Add(ex.Message); } catch (Exception ex) { response.Result = Result.FAIL; response.ResultMessages.Add(ex.ToString()); } } } catch (Exception ex) { response.Result = Result.FAIL; response.ResultMessages.Add(ex.Message); mLogger.Error(ex); } return response; }
public NippsModuleResponse GetByName(NippsModuleRequest nippsModuleRequest) { NippsModuleResponse response = new NippsModuleResponse(); response.ResultMessages = new List<string>(); if (nippsModuleRequest == null || nippsModuleRequest.NippsModules == null || nippsModuleRequest.NippsModules.Count() == 0 || string.IsNullOrEmpty(nippsModuleRequest.NippsModules[0].ModuleName) ) { response.Result = Result.FAIL; response.ResultMessages.Add("NippsModules can not be null."); return response; } try { using (ILifetimeScope scope = NippsIoCHelper.IoCContainer.BeginLifetimeScope()) { IGenericLogicV2<NippsModule> logModuleLogic = scope.Resolve<IGenericLogicV2<NippsModule>>(); bool succeededOne = false; response.NippsModules = new List<NippsModule>(); response.Result = Result.OK; foreach (NippsModule logModule in nippsModuleRequest.NippsModules) { try { response.NippsModules.Add(logModuleLogic.GetByName(logModule.ModuleName)); succeededOne = true; } catch (Exception ex) { if (succeededOne) response.Result = Result.SUCCESSWITHWARN; else response.Result = Result.FAIL; response.ResultMessages.Add(ex.ToString()); } } } } catch (Exception ex) { response.Result = Result.FAIL; response.ResultMessages.Add(ex.Message); mLogger.Error(ex); } return response; }