Пример #1
0
        public async Task <bool> CreateDiagnose(string patientId, string doctorId, DiagnoseServiceModel diagnoseServiceModel)
        {
            Patient patientFromDb = await context.Patients.SingleOrDefaultAsync(patient => patient.Id == patientId);

            if (patientFromDb == null)
            {
                throw new ArgumentNullException(nameof(patientFromDb));
            }

            Doctor doctorFromDb = await context.Doctors.SingleOrDefaultAsync(doctor => doctor.HospitalMSUserId == doctorId);

            if (doctorFromDb == null)
            {
                throw new ArgumentNullException(nameof(doctorFromDb));
            }

            Diagnose diagnose = AutoMapper.Mapper.Map <Diagnose>(diagnoseServiceModel);

            diagnose.Date    = DateTime.UtcNow;
            diagnose.Patient = patientFromDb;
            diagnose.Doctor  = doctorFromDb;

            context.Diagnoses.Add(diagnose);

            int result = await context.SaveChangesAsync();

            return(result > 0);
        }
Пример #2
0
        public async Task <IActionResult> Create(string id, DiagnoseCreateInputModel diagnoseCreateInputModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(diagnoseCreateInputModel));
            }

            DiagnoseServiceModel diagnoseServiceModel = AutoMapper.Mapper.Map <DiagnoseServiceModel>(diagnoseCreateInputModel);

            var doctorId = User.FindFirst(ClaimTypes.NameIdentifier).Value;

            await diagnoseService.CreateDiagnose(id, doctorId, diagnoseServiceModel);


            return(Redirect("/Patient/All"));
        }