Exemple #1
0
        public IActionResult AnalyzeTest(int id)
        {
            int presId;
            presCommentViewModel prescription;

            context = HttpContext.RequestServices.GetService(typeof(BCare.data.BcareContext)) as BcareContext;
            String cookie = Request.Cookies["Session"];

            presId = context.GetPresByBloodTest(id);
            if (TempData["errorMessage"] != null)
            {
                ViewBag.Error = TempData["errorMessage"];
            }
            if (presId == 0)
            {
                Models.GA.Population po = new Models.GA.Population(id, context);
                for (int i = 0; i < 499; i++)
                {
                    po.NextGeneration();
                }
                po.WriteNextGeneration();
                Models.GA.Individual bestResult = po.bestList[0];
                context.SetNewPrescription(id, DateTime.Now, 123123123, bestResult.text);
                presId = context.GetPresByBloodTest(id);
                if (!bestResult.noExecptions)
                {
                    foreach (int med in bestResult.hashMed)
                    {
                        context.SetNewPrescriptionDetails(presId, med, RandomNumber(1, 3), RandomNumber(5, 8), "");
                    }
                }
                prescription = context.getPrescriptionDetails(presId, id);
                return(View(prescription));
            }
            else
            {
                prescription = context.getPrescriptionDetails(presId, id);
                return(View(prescription));
            }
        }