Example #1
0
        public IActionResult Get(int id)
        {
            ExamDb examFind = _examContext.Exam.Find(id);

            if (examFind == null)
            {
                return(NotFound("Not found"));
            }
            Exam examDTO = new Exam(examFind.ExamId, examFind.Date, examFind.OpenMeasurementPx, examFind.ShutMeasurementPx, examFind.ResultMeasurementCm, examFind.PatientId, examFind.UsersId);

            return(Ok(examDTO));
        }
Example #2
0
        public static void Main(string[] args)
        {
            IWebHost webHost = CreateWebHostBuilder(args).Build();

            using (IServiceScope serviceScope = webHost.Services.CreateScope())
            {
                using (IntellectDbContext intellectDbContext = serviceScope.ServiceProvider.GetRequiredService <IntellectDbContext>())
                {
                    var roleManager = serviceScope.ServiceProvider.GetRequiredService <RoleManager <Microsoft.AspNetCore.Identity.IdentityRole> >();
                    ExamDb.Seed(intellectDbContext, roleManager);
                }
            }

            webHost.Run();
        }
Example #3
0
        public IActionResult Put(int id, Exam newExam)
        {
            if (newExam == null)
            {
                return(NotFound("Not found"));
            }
            UsersDb   users   = _examContext.Users.FirstOrDefault(u => u.UsersId == newExam.UsersId);
            PatientDb patient = _examContext.Patient.FirstOrDefault(p => p.PatientId == newExam.PatientId);
            ExamDb    exam    = new ExamDb(newExam, patient, users);

            exam.ExamId = id;
            _examContext.Exam.Update(exam);
            _examContext.SaveChanges();
            return(Ok(newExam));
        }
Example #4
0
        public async Task <IActionResult> Post(Exam exam)
        {
            if (exam == null)
            {
                return(NotFound("Empty exam"));
            }
            UsersDb   users   = _examContext.Users.FirstOrDefault(u => u.UsersId == exam.UsersId);
            PatientDb patient = _examContext.Patient.FirstOrDefault(p => p.PatientId == exam.PatientId);
            ExamDb    newExam = new ExamDb(exam, patient, users);
            await _examContext.Exam.AddAsync(newExam);

            await _examContext.SaveChangesAsync();

            return(Ok(_examContext.Exam.ToList()));
        }