コード例 #1
0
        public IActionResult Create([FromBody] EntidadEntity EntidadParam)
        {
            string json = "";
            var    IP   = Request.HttpContext.Connection.RemoteIpAddress.ToString();

            if (EntidadParam.IPInsercion == null)
            {
                EntidadParam.IPInsercion = IP;
            }

            json = JsonConvert.SerializeObject(EntidadParam);

            logger.Debug("***JSON Inicio***");
            logger.Debug(json);
            logger.Debug("***JSON Inicio***");

            List <ResultDataAppService> Result = new List <ResultDataAppService>();
            bool   ResultBool    = false;
            string MensajeString = "Error";

            try
            {
                ctxModel.Entidad.Add(EntidadParam);
                ctxModel.SaveChanges();
                ResultBool    = true;
                MensajeString = "Entidad Creada.";
            }
            catch (Exception ErroresControlados)
            {
                MensajeString = ErroresControlados.GetBaseException().Message;
                logger.Error(MensajeString);
                ResultBool = false;
            }
            Result.Add(new ResultDataAppService()
            {
                Boolean = ResultBool, String = MensajeString
            });
            json = JsonConvert.SerializeObject(Result);
            logger.Debug("***JSON FIN***");
            logger.Debug(json);
            logger.Debug("***JSON FIN***");
            return(this.Ok(Result));
        }
コード例 #2
0
        public IActionResult Create([FromBody] GrupoEntity GrupoEntityParam)
        {
            string json = "";

            json = JsonConvert.SerializeObject(GrupoEntityParam);

            logger.Debug("***JSON Inicio***");
            logger.Debug(json);
            logger.Debug("***JSON Inicio***");

            List <ResultDataAppService> Result = new List <ResultDataAppService>();
            bool   ResultBool    = false;
            string MensajeString = "Error";

            try
            {
                ctxModel.Grupo.Add(GrupoEntityParam);
                ctxModel.SaveChanges();
                ResultBool    = true;
                MensajeString = "Grupo Creado.";
            }
            catch (Exception ErroresControlados)
            {
                MensajeString = ErroresControlados.GetBaseException().Message;
                logger.Error(MensajeString);
                ResultBool = false;
            }
            Result.Add(new ResultDataAppService()
            {
                Boolean = ResultBool, String = MensajeString
            });
            json = JsonConvert.SerializeObject(Result);
            logger.Debug("***JSON FIN***");
            logger.Debug(json);
            logger.Debug("***JSON FIN***");
            return(this.Ok(Result));
        }