Пример #1
0
        public async Task <ActionResult> PatientAskForGetInfoPatient()
        {
            string username = HttpContext.User.Identity.Name;
            var    patient  = await PatientFacade.GetPatientByUsernameAsync(username);

            return(await GetPatientInfo(patient));
        }
Пример #2
0
        public async Task <ActionResult> Create(PatientCreateModel patientCreateModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(patientCreateModel));
            }
            PatientDto patientDto = new PatientDto
            {
                Username             = patientCreateModel.Username,
                Password             = patientCreateModel.Password,
                Name                 = patientCreateModel.Name,
                Surname              = patientCreateModel.Surname,
                DateOfBirth          = patientCreateModel.DateOfBirth,
                Email                = patientCreateModel.Email,
                IdentificationNumber = patientCreateModel.IdentificationNumber,
                ProfileCreationDate  = DateTime.Now
            };

            if (await PatientFacade.GetPatientByUsernameAsync(patientCreateModel.Username) != null ||
                await DoctorFacade.GetDoctorByUsernameAsync(patientCreateModel.Username) != null)
            {
                ModelState.AddModelError("Username", "Account with that username already exists");
                return(View(patientCreateModel));
            }
            var patientId = await PatientFacade.RegisterPatient(patientDto);

            return(RedirectToAction("Index", "Home"));
        }
Пример #3
0
        public async Task <ActionResult> Update()
        {
            var patientData = await PatientFacade.GetPatientByUsernameAsync(HttpContext.User.Identity.Name);

            PatientUpdateModel patientUpdateModel = new PatientUpdateModel
            {
                Name    = patientData.Name,
                Surname = patientData.Surname,
                Email   = patientData.Email
            };

            return(View(patientUpdateModel));
        }
Пример #4
0
        public async Task <ActionResult> Update(PatientUpdateModel patientUpdateModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(patientUpdateModel));
            }
            var username        = HttpContext.User.Identity.Name;
            var patientToUpdate = await PatientFacade.GetPatientByUsernameAsync(username);

            patientToUpdate.Email   = patientUpdateModel.Email;
            patientToUpdate.Name    = patientUpdateModel.Name;
            patientToUpdate.Surname = patientUpdateModel.Surname;
            await PatientFacade.EditPatientAsync(patientToUpdate);

            return(RedirectToAction("Index", "Home"));
        }
Пример #5
0
        public async Task <ActionResult> AddClickedPatient()
        {
            var username     = Request.QueryString["Username"];
            var foundPatient = await PatientFacade.GetPatientByUsernameAsync(username);

            var loggedDoctor = await DoctorFacade.GetDoctorByUsernameAsync(HttpContext.User.Identity.Name);

            var relationshipGuid = await DoctorToPatientFacade.FindJoiningRelationshipId(loggedDoctor.Id, foundPatient.Id);

            if (relationshipGuid == Guid.Empty)
            {
                var doctorToPatientDto = new DoctorToPatientDto {
                    DoctorDto = loggedDoctor, PatientDto = foundPatient
                };
                await DoctorToPatientFacade.Create(doctorToPatientDto);
            }
            return(RedirectToAction("GetPatientsForDoctor", "Doctor", new { Username = loggedDoctor.Username }));
        }