Esempio n. 1
0
            static void CargarFormularioParaAnalisis(FormularioParaAnalisis formulario)
            {
                try
                {
                    DataContext dataContext = new DataContext();
                    FormuarioParaAnalisisService formuario = new FormuarioParaAnalisisService(dataContext);
                    string Uri = "http://40.118.242.96:12600";
                    Console.WriteLine("Autenticando ...");
                    HttpClient httpClient = new HttpClient();
                    httpClient.BaseAddress = new Uri(Uri);

                    Random rand = new Random(DateTime.Now.Second);
                    Console.WriteLine("Comienza Add()");

                    string              dtojson   = JsonConvert.SerializeObject(formuario); // aca va el DTO de formulario
                    HttpContent         content2  = new StringContent(dtojson, Encoding.UTF8, "application/json");
                    HttpResponseMessage response2 = httpClient.PostAsync("/api/FormularioParaAnalisis/Add", content2).Result;
                    if (response2.StatusCode == System.Net.HttpStatusCode.OK)
                    {
                        Console.WriteLine(response2.StatusCode);
                        Console.WriteLine("Fin Add() Formulario");
                    }
                    else
                    {
                        Console.WriteLine(response2.ReasonPhrase);
                        Console.WriteLine("Error Add()");
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                //}
            }
 //[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme, Roles = "Admin, App")]
 public ActionResult Add([FromBody] FormularioParaAnalisis FPA)
 {
     try
     {
         DataContext dataContext = new DataContext();
         FormuarioParaAnalisisService formuarioParaAnalisisService = new FormuarioParaAnalisisService(dataContext);
         formuarioParaAnalisisService.Add(FPA);
         return(Ok());
     }
     catch (Exception e)
     {
         return(BadRequest(Tools.ExceptionMessage(e)));
     }
 }
        public void CargarFormularios()
        {
            List <FormularioParaAnalisis> ListaFPA = new List <FormularioParaAnalisis>();

            AntEmp1Service         antEmp1Service1        = new AntEmp1Service(dataContext);
            AntEmp2Service         antEmp1Service2        = new AntEmp2Service(dataContext);
            EPCService             ePCService             = new EPCService(dataContext);
            SignosYsintomasService signosYsintomasService = new SignosYsintomasService(dataContext);
            PacienteService        pacienteService        = new PacienteService(dataContext);
            DomicilioService       domicilioService       = new DomicilioService(dataContext);

            List <AntecedenteEpidemiologicos1>       ant1 = antEmp1Service1.GetAntEmp1();
            List <AntecedenteEpidemiologicos2>       ant2 = antEmp1Service2.GetAntEmp2();
            List <EnfermedadesPreviasComorbilidades> epc  = ePCService.GetEPC();
            List <SignosYSintomas> sys        = signosYsintomasService.GetSignosYsintomas();
            List <Paciente>        pacientes  = pacienteService.GetPacientes();
            List <Domicilio>       domicilios = domicilioService.GetDomicilios();


            for (int i = 0; i < 10; i++)
            {
                FormularioParaAnalisis FPA = new FormularioParaAnalisis();

                FPA.AntecedenteEpidemiologicos1       = ant1[i];
                FPA.AntecedenteEpidemiologicos2       = ant2[i];
                FPA.SignosYSintomas                   = sys[i];
                FPA.EnfermedadesPreviasComorbilidades = epc[i];
                FPA.Paciente            = pacientes[i];
                FPA.FechaDeCreacion     = DateTime.Parse($"2/{(i + 1).ToString()}/2020", System.Globalization.CultureInfo.InvariantCulture);
                FPA.EstadoDelFormulario = EstadoDelFormulario.GENERADOS;

                ListaFPA.Add(FPA);
            }

            dataContext.ListaFormularioParaAnalisis.AddRange(ListaFPA);
            dataContext.SaveChanges();
        }
 public void Delete(FormularioParaAnalisis FPA)
 {
     dataContext.ListaFormularioParaAnalisis.Remove(FPA);
     dataContext.SaveChanges();
 }
 public void Add(FormularioParaAnalisis FPA)
 {
     dataContext.ListaFormularioParaAnalisis.Add(FPA);
     dataContext.SaveChanges();
 }
        public FormularioParaAnalisis SendFormulario()
        {
            FormularioParaAnalisis FPA = new FormularioParaAnalisis();

            AntEmp1Service         antEmp1Service1        = new AntEmp1Service(dataContext);
            AntEmp2Service         antEmp1Service2        = new AntEmp2Service(dataContext);
            EPCService             ePCService             = new EPCService(dataContext);
            SignosYsintomasService signosYsintomasService = new SignosYsintomasService(dataContext);
            PacienteService        pacienteService        = new PacienteService(dataContext);
            DomicilioService       domicilioService       = new DomicilioService(dataContext);

            List <AntecedenteEpidemiologicos1>       ant1 = antEmp1Service1.GetAntEmp1();
            List <AntecedenteEpidemiologicos2>       ant2 = antEmp1Service2.GetAntEmp2();
            List <EnfermedadesPreviasComorbilidades> epc  = ePCService.GetEPC();
            List <SignosYSintomas> sys        = signosYsintomasService.GetSignosYsintomas();
            List <Paciente>        pacientes  = pacienteService.GetPacientes();
            List <Domicilio>       domicilios = domicilioService.GetDomicilios();


            var seed   = Environment.TickCount;
            var random = new Random(seed);
            var i      = random.Next(0, 9);

            FPA.AntecedenteEpidemiologicos1 = ant1[i];

            var seed1   = Environment.TickCount;
            var random1 = new Random(seed1);
            var v       = random.Next(0, 9);

            FPA.AntecedenteEpidemiologicos2 = ant2[v];

            var seed2   = Environment.TickCount;
            var random2 = new Random(seed2);
            var c       = random.Next(0, 9);

            FPA.SignosYSintomas = sys[c];

            var seed3   = Environment.TickCount;
            var random3 = new Random(seed3);
            var x       = random.Next(0, 9);

            FPA.EnfermedadesPreviasComorbilidades = epc[x];

            var seed5   = Environment.TickCount;
            var random5 = new Random(seed5);
            var e       = random.Next(0, 9);
            var seed6   = Environment.TickCount;
            var random6 = new Random(seed6);
            var h       = random.Next(0, 9);

            pacientes[e].NroDeDocumento = (e * h).ToString();
            FPA.Paciente = pacientes[e];

            var seed4   = Environment.TickCount;
            var random4 = new Random(seed4);
            var z       = random.Next(0, 9);

            FPA.FechaDeCreacion     = DateTime.Parse($"2/{(z + 1).ToString()}/2020", System.Globalization.CultureInfo.InvariantCulture);
            FPA.EstadoDelFormulario = EstadoDelFormulario.GENERADOS;

            return(FPA);
        }