Пример #1
0
        // GET: LabTests/Details/5
        public async Task <IActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var LabTest = tests.GetById(id);/*await _context.TblLabTests
                                             * .Include(t => t.BiodataNavigation)
                                             * .Include(t => t.MethodNavigation)
                                             * .FirstOrDefaultAsync(m => m.Id == id);*/


            //var json = JsonConvert.SerializeObject(LabTest.LabTest, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore, ReferenceLoopHandling = ReferenceLoopHandling.Ignore });

            if (LabTest == null)
            {
                return(NotFound());
            }

            HttpContext.Session.SetString("biodata_details_token", "");

            var _indicators = indicators.GetAll();

            foreach (var i in LabTest.Indicators)
            {
                i.IndicatorName = _indicators.FirstOrDefault(x => x.Id == i.Indicator).IndicatorName;
            }

            var _specimen = specimen.GetAll();

            foreach (var s in LabTest.Specimen)
            {
                s.SpecimenName = _specimen.FirstOrDefault(x => x.Id == s.Specimen).Type;
            }

            if (LabTest.LabTest.Approved == null)
            {
                LabTest.LabTest.Approved = false;
            }

            ViewData["Ready"] = Ready4Approval(LabTest.LabTest);

            return(View(LabTest));
        }
        public LabTestDetailsViewModel(TblBiodata _BioData, IMethodRepos _methods, ISpecimenRepos _specimen) //main to create
        {                                                                                                    //perfect
            BioData = _BioData;
            //Method = _method;
            methods = _methods;

            //Indicators = new List<TblLabTestsIndicatorsValues>();
            Specimen = new List <TblLabTestsSpecimen>();

            LabTest          = new TblLabTests();
            LabTest.Approved = false;
            LabTest.Biodata  = _BioData.Id;
            //LabTest.Method = _method.Id;


            /*foreach(var i in _method.TlkpTestIndicators)
             * {
             *  TblLabTestsIndicatorsValues v = new TblLabTestsIndicatorsValues();
             *  v.Indicator = i.Id;
             *  v.Method = _method.Id;
             *  LabTest.TblLabTestsIndicatorsValues.Add(v);
             *
             *  Indicators.Add(v);
             *
             *
             * }*/


            foreach (var t in _specimen.GetAll())
            {
                TblLabTestsSpecimen s = new TblLabTestsSpecimen();
                s.Specimen     = t.Id;
                s.SpecimenName = t.Type;
                LabTest.TblLabTestsSpecimen.Add(s);
                Specimen.Add(s);
            }
        }