private NippsParameterResponse AddUpdateRemoveParameter(NippsParameterRequest nippsParameterRequest, NippsParameterOperation operation = NippsParameterOperation.ADD) { NippsParameterResponse parameterResponse = new NippsParameterResponse(); parameterResponse.ResultMessages = new List<String>(); if (nippsParameterRequest != null && nippsParameterRequest.NippsParameters != null && nippsParameterRequest.NippsParameters.Count > 0) { Boolean succeededOne = false; try { parameterResponse.NippsParameters = new List<NippsParameter>(); using (ILifetimeScope scope = NippsIoCHelper.IoCContainer.BeginLifetimeScope()) { INippsParameterLogicV2 nippsParameterLogic = scope.Resolve<INippsParameterLogicV2>(); foreach (NippsParameter nippsParameter in nippsParameterRequest.NippsParameters) { try { if (operation == NippsParameterOperation.UPDATE) nippsParameterLogic.UpdateParameter(nippsParameter.CategoryName, nippsParameter.ParameterName, nippsParameter.ParameterValue); else if (operation == NippsParameterOperation.REMOVE) nippsParameterLogic.RemoveParameter(nippsParameter.CategoryName, nippsParameter.ParameterName); else nippsParameterLogic.AddParameter(nippsParameter.CategoryName, nippsParameter.ParameterName, nippsParameter.ParameterValue); succeededOne = true; } catch (Exception ex) { if (succeededOne) parameterResponse.Result = Result.SUCCESSWITHWARN; else parameterResponse.Result = Result.FAIL; parameterResponse.ResultMessages.Add(ex.ToString()); mLogger.Error(ex.ToString()); } } } } catch (Exception ex) { parameterResponse.Result = Result.FAIL; parameterResponse.ResultMessages.Add(ex.ToString()); mLogger.Error(ex.ToString()); } } else { parameterResponse.Result = Result.FAIL; parameterResponse.ResultMessages.Add(ResultMessagesHelper.ToString(ResultMessages.REQUEST_INVALID_PARAMETER)); } return parameterResponse; }
private NippsParameterResponse AddUpdateRemoveParameter(NippsParameterRequest nippsParameterRequest, NippsParameterOperation operation = NippsParameterOperation.ADD) { NippsParameterResponse parameterResponse = new NippsParameterResponse(); parameterResponse.ResultMessages = new List <String>(); if (nippsParameterRequest != null && nippsParameterRequest.NippsParameters != null && nippsParameterRequest.NippsParameters.Count > 0) { Boolean succeededOne = false; try { parameterResponse.NippsParameters = new List <NippsParameter>(); using (ILifetimeScope scope = NippsIoCHelper.IoCContainer.BeginLifetimeScope()) { INippsParameterLogicV2 nippsParameterLogic = scope.Resolve <INippsParameterLogicV2>(); foreach (NippsParameter nippsParameter in nippsParameterRequest.NippsParameters) { try { if (operation == NippsParameterOperation.UPDATE) { nippsParameterLogic.UpdateParameter(nippsParameter.CategoryName, nippsParameter.ParameterName, nippsParameter.ParameterValue); } else if (operation == NippsParameterOperation.REMOVE) { nippsParameterLogic.RemoveParameter(nippsParameter.CategoryName, nippsParameter.ParameterName); } else { nippsParameterLogic.AddParameter(nippsParameter.CategoryName, nippsParameter.ParameterName, nippsParameter.ParameterValue); } succeededOne = true; } catch (Exception ex) { if (succeededOne) { parameterResponse.Result = Result.SUCCESSWITHWARN; } else { parameterResponse.Result = Result.FAIL; } parameterResponse.ResultMessages.Add(ex.ToString()); mLogger.Error(ex.ToString()); } } } } catch (Exception ex) { parameterResponse.Result = Result.FAIL; parameterResponse.ResultMessages.Add(ex.ToString()); mLogger.Error(ex.ToString()); } } else { parameterResponse.Result = Result.FAIL; parameterResponse.ResultMessages.Add(ResultMessagesHelper.ToString(ResultMessages.REQUEST_INVALID_PARAMETER)); } return(parameterResponse); }