public async Task <ActionResult <Patient> > PostPersonAsPatient(PersonRegistrationDTO person)
        {
            using (var transaction = new TransactionScope())
            {
                if (!(_peopleController.RegisterUser(person) is CreatedResult result))
                {
                    return(BadRequest(BadRequestEmptyJsonResult));
                }

                Person  user       = _peopleRepository.GetByEmail(person.Email);
                Patient newPatient = new Patient()
                {
                    Id = user.Id, IdNavigation = user
                };


                if (!(await PostPatient(newPatient) is CreatedResult resultDoctor))
                {
                    return(BadRequest(BadRequestEmptyJsonResult));
                }
                //_repository.Insert(newPatient);
                //_repository.Save();

                transaction.Complete();

                user.Patient = newPatient;
                return(Created("", user));
            }
        }
Example #2
0
 public void Insert(PersonRegistrationDTO a)
 {
     _context.Person.Add(new Person
     {
         Name      = a.Name,
         Lastname  = a.Lastname,
         Birthdate = a.Birthdate,
         Gender    = a.Gender,
         Email     = a.Email,
         Password  = a.Password.Value,
         Pesel     = a.Pesel
     });
 }
Example #3
0
        public ActionResult RegisterUser(PersonRegistrationDTO newPerson)
        {
            newPerson.Password.Value = AuthenticationService.CreateHash(newPerson.Password.Value);

            if (_repository.Exists(newPerson.Email))
            {
                return(Conflict(ConflictJsonResult("User with that email address already exists")));
            }

            newPerson.Email = newPerson.Email.ToLower();

            _repository.Insert(newPerson);
            _repository.Save();

            return(Created("", CreatedEmptyJsonResult));
        }