Exemple #1
0
        public void Create(DentistDTO dentistDTO)
        {
            var dentist = DentistMapper.DTOtoApplicationUser(dentistDTO);
            PasswordHasher <ApplicationUser> passwordHasher = new PasswordHasher <ApplicationUser>();
            var passwordHash = passwordHasher.HashPassword(dentist, dentistDTO.Password);

            dentist.PasswordHash = passwordHash;

            _context.ApplicationUsers.Add(dentist);

            var role = _context.ApplicationRole.Where(r => r.Name.Equals("Dentist")).Single();

            dentist.UserRoles.Add(new ApplicationUserRole()
            {
                User = dentist,
                Role = role,
            });

            var userId = _userProviderService.GetUserId();

            var affiliateId = _context.ApplicationUsers
                              .Where(u => u.Id.Equals(userId))
                              .Select(u => u.AffiliateId)
                              .Single();

            var affiliate = _context.Affiliates.Find(affiliateId);

            dentist.Affiliate = affiliate;

            _context.SaveChanges();
        }
Exemple #2
0
        public void Update(DentistDTO userDTO)
        {
            var applicationUser = _context.ApplicationUsers
                                  .SingleOrDefault(x => x.Id.Equals(userDTO.Id));

            applicationUser.FirstName   = userDTO.FirstName;
            applicationUser.LastName    = userDTO.LastName;
            applicationUser.PhoneNumber = userDTO.PhoneNumber;

            _context.SaveChanges();
        }