Example #1
0
        public string addAgentFacade(AgentModel agentModel)
        {
            responseOperation = new MessageInfo();
            try
            {
                //Add arguments to  list
                List<keyValue> lstParams = new List<keyValue>();
                //lstParams.Add(new keyValue("agent", agent)); lstParams.Add(new keyValue("idUser", idUser));
                string method = string.Format("{0}.{1}", MethodBase.GetCurrentMethod().DeclaringType.FullName, MethodBase.GetCurrentMethod().Name);

                ObjectParameter prmOutIdAgent = new ObjectParameter("prmOutIdAgent", typeof(int));
                ObjectParameter prmOutResult = new ObjectParameter("prmOutResult", typeof(int));

                objController.addAgentController(agentModel, ref prmOutIdAgent,    ref prmOutResult);

                int op = Int32.Parse(prmOutResult.Value.ToString());
                switch (op)
                {

                    case 0:
                        responseOperation.messageID = 100;
                        break;

                    case -1:
                        responseOperation.messageID = 101;
                        break;
                    case -2:
                        responseOperation.messageID = 102;
                        break;
                    case -3:
                        responseOperation.messageID = 103;
                        break;
                }

                DataMessage.ObtenerMensaje(responseOperation);
                responseOperation.MessageLog = string.Format(" It was created on record [Agent] with ID :", Int32.Parse(prmOutIdAgent.Value.ToString()));
                Log4NetHelper.addLog(Log4NetHelper.levelLog.INFO,  string.Format(" It was created on record [Agent] with ID :", prmOutIdAgent.ToString()));
                return JavaScriptSerializerHelper.GetString(new object[] { responseOperation, null });
            }
            catch (Exception exc)
            {
                responseOperation.messageID = 3;
                responseOperation.MessageLog = exc.ToString();
                DataMessage.ObtenerMensaje(responseOperation);
                Log4NetHelper.addLog(Log4NetHelper.levelLog.ERROR, "An exception is presented  .", exc);
                return JavaScriptSerializerHelper.GetString(new object[] { responseOperation, null });
            }
        }