コード例 #1
0
        public async Task <string> CreatePatientAsync(PatientUpdateInfoViewModel input)
        {
            Patient patient = new Patient
            {
                FirstName       = input.FirstName,
                LastName        = input.LastName,
                EGN             = input.EGN,
                AddressId       = input.AddressId,
                DoctorId        = input.DoctorId,
                MedicalRecordId = input.MedicalRecordId,
            };

            await this.patientRepository.AddAsync(patient);

            await this.patientRepository.SaveChangesAsync();

            return(patient.Id);
        }
コード例 #2
0
        public async Task <IActionResult> CreateAsync(PatientUpdateInfoViewModel patientInput)
        {
            if (!this.ModelState.IsValid)
            {
                this.TempData["Infomessage"] = "Invalid input";
                return(this.View(patientInput));
            }

            if (this.patientService.PatientExists(patientInput.FirstName, patientInput.LastName, patientInput.EGN))
            {
                this.TempData["Infomessage"] = "Such patient exists";
                return(this.View(patientInput));
            }

            await this.patientService.CreatePatientAsync(patientInput);

            var user = await this.userManager.GetUserAsync(this.User);

            await this.userManager.AddToRoleAsync(user, "Patient");

            return(this.Redirect("/EGovServices/SelectProfileSetOptions"));
        }