Exemple #1
0
        public async Task <JsonResult> AddSNC(SncDTO model)
        {
            model.UserName = User.Identity.Name;

            await _sncService.AddSNCAsync(model);

            return(Json(new { Success = true }));
        }
Exemple #2
0
        public async Task AddSNCAsync(SncDTO model)
        {
            var asp_gral          = new List <SNSListasDTO>();
            var sedacion          = new List <SNSListasDTO>();
            var lab               = new List <SNSListasDTO>();
            var img               = new List <SNSListasDTO>();
            var sx_abs            = new List <SNSListasDTO>();
            var sx_abs_medicacion = new List <SNSListasDTO>();
            var conv              = new List <SNSListasDTO>();

            if (!string.IsNullOrWhiteSpace(model.AspectoGralJSON))
            {
                asp_gral = JsonConvert.DeserializeObject <List <SNSListasDTO> >(model.AspectoGralJSON);
            }

            var asp_gral_dt = ListToDataTable(asp_gral);

            var pAspGral = new SqlParameter("@AspectoGral", SqlDbType.Structured)
            {
                TypeName = "dbo.SNCList",
                Value    = asp_gral_dt
            };

            if (!string.IsNullOrWhiteSpace(model.SedacionMedicamentoJSON))
            {
                sedacion = JsonConvert.DeserializeObject <List <SNSListasDTO> >(model.SedacionMedicamentoJSON);
            }

            var sedacion_dt = ListToDataTable(sedacion);

            var pSedacion = new SqlParameter("@Sedacion", SqlDbType.Structured)
            {
                TypeName = "dbo.SNCList",
                Value    = sedacion_dt
            };

            if (!string.IsNullOrWhiteSpace(model.LaboratorioJSON))
            {
                lab = JsonConvert.DeserializeObject <List <SNSListasDTO> >(model.LaboratorioJSON);
            }

            var lab_dt = ListToDataTable(lab);

            var pLab = new SqlParameter("@Laboratorio", SqlDbType.Structured)
            {
                TypeName = "dbo.SNCList",
                Value    = lab_dt
            };

            if (!string.IsNullOrWhiteSpace(model.ImagenesJSON))
            {
                img = JsonConvert.DeserializeObject <List <SNSListasDTO> >(model.ImagenesJSON);
            }

            var img_dt = ListToDataTable(img);

            var pImg = new SqlParameter("@Imagenes", SqlDbType.Structured)
            {
                TypeName = "dbo.SNCList",
                Value    = img_dt
            };

            if (!string.IsNullOrWhiteSpace(model.SxAbstinenciaJSON))
            {
                sx_abs = JsonConvert.DeserializeObject <List <SNSListasDTO> >(model.SxAbstinenciaJSON);
            }

            var sx_abs_dt = ListToDataTable(sx_abs);

            var pSxAbs = new SqlParameter("@SxAbstinencia", SqlDbType.Structured)
            {
                TypeName = "dbo.SNCList",
                Value    = sx_abs_dt
            };

            if (!string.IsNullOrWhiteSpace(model.SxAbstinenciaMedicacionJSON))
            {
                sx_abs_medicacion = JsonConvert.DeserializeObject <List <SNSListasDTO> >(model.SxAbstinenciaMedicacionJSON);
            }

            var sx_abs_medicacion_dt = ListToDataTable(sx_abs_medicacion);

            var pSxAbsMed = new SqlParameter("@SxAbstinenciaMedicacion", SqlDbType.Structured)
            {
                TypeName = "dbo.SNCList",
                Value    = sx_abs_medicacion_dt
            };

            if (!string.IsNullOrWhiteSpace(model.ConocidoConvulsionadorJSON))
            {
                conv = JsonConvert.DeserializeObject <List <SNSListasDTO> >(model.ConocidoConvulsionadorJSON);
            }

            var conv_dt = ListToDataTable(conv);

            var pConv = new SqlParameter("@Convulsionador", SqlDbType.Structured)
            {
                TypeName = "dbo.SNCList",
                Value    = conv_dt
            };

            List <SqlParameter> parametros = new List <SqlParameter>
            {
                new SqlParameter("PacienteId", model.PacienteId),
                pAspGral,
                new SqlParameter("SedacionId", model.SedacionId),
                pSedacion,
                new SqlParameter("ValorSedacion", model.ValorSedacion),
                pLab,
                pImg,
                new SqlParameter("SxAbstinenciaId", model.SxAbstinenciaId),
                pSxAbs,
                pSxAbsMed,
                new SqlParameter("ConocidoConvulsionadorId", model.ConocidoConvulsionadorId),
                pConv,
                new SqlParameter("Eventos", (model.Eventos ?? "")),
                new SqlParameter("Planes", (model.Planes ?? "")),
                new SqlParameter("UserName", model.UserName)
            };

            await ExecuteNonQueryAsync("sp_AddSNC", _connectionString, CommandType.StoredProcedure, parametros.ToArray());
        }