Example #1
0
        public HealthcareProviderAccountResponse Create(HealthcareProviderCreateRequest model)
        {
            // validate
            if (_context.HealthcareProviders.Any(x => x.Email == model.Email))
            {
                throw new AppException($"Email '{model.Email}' is already registered");
            }

            // map model to new account object
            var account = _mapper.Map <HealthcareProvider>(model);

            account.Created  = DateTime.UtcNow;
            account.Verified = DateTime.UtcNow;

            // hash password
            account.PasswordHash = BC.HashPassword(model.Password);

            // save account
            _context.HealthcareProviders.Add(account);
            _context.SaveChanges();

            return(_mapper.Map <HealthcareProviderAccountResponse>(account));
        }
        public ActionResult <HealthcareProviderAccountResponse> Create(HealthcareProviderCreateRequest model)
        {
            var account = _accountService.Create(model);

            return(Ok(account));
        }