public NippsModuleResponse Add(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.Result = Result.OK;

                    foreach (NippsModule logModule in nippsModuleRequest.NippsModules)
                    {
                        try
                        {
                            logModuleLogic.Add(logModule);
                            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);
        }
        public NippsLogResponse Add([FromBody] NippsLogRequest request)
        {
            NippsLogResponse response = new NippsLogResponse();

            response.ResultMessages = new List <string>();

            if (request == null || request.NippsLogs == null || request.NippsLogs.Count() == 0 || string.IsNullOrEmpty(request.NippsLogs[0].LogModuleName))
            {
                response.Result = Result.FAIL;
                response.ResultMessages.Add("NippsLog can not be null.");
                return(response);
            }

            try
            {
                using (ILifetimeScope scope = NippsIoCHelper.IoCContainer.BeginLifetimeScope())
                {
                    IGenericLogicV2 <NippsLog> nippsLogLogic = scope.Resolve <IGenericLogicV2 <NippsLog> >();
                    bool succeededOne = false;

                    response.Result = Result.OK;

                    foreach (NippsLog nippsLog in request.NippsLogs)
                    {
                        try
                        {
                            nippsLogLogic.Add(nippsLog);
                            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);
                RestHelper.ReportCriticalError("LogManager", ex.ToString());
            }

            return(response);
        }