示例#1
0
        public async Task <UsersViewModel> RegisterAsync(RegisterViewModel registerViewModel)
        {
            var usermodel = new UsersViewModel()
            {
                Id           = Guid.NewGuid(),
                Sort         = 0,
                Type         = 0,
                NickName     = registerViewModel.NickName,
                Email        = registerViewModel.Identifier,
                RegisterTime = DateTime.Now,
                RegisterIp   = registerViewModel.IP
            };
            var userauth = new UserAuths(Guid.NewGuid())
            {
                UserId           = usermodel.Id,
                IdentityType     = "email",
                Identifier       = registerViewModel.Identifier,
                Credential       = registerViewModel.Credential.ToMd5(),
                State            = 1,
                AuthTime         = DateTime.Now,
                LastModifiedTime = DateTime.Now,
                Verified         = true,
            };
            var user   = _mapper.Map <Users>(usermodel);
            var entity = await _usersRepository.RegisterAsync(user, userauth);

            var result = _mapper.Map <UsersViewModel>(entity);

            return(result);
        }
示例#2
0
        public async Task <Users> RegisterAsync(Users user, UserAuths userauth)
        {
            Db.Users.Add(user);
            Db.UserAuths.Add(userauth);
            var result = await Db.SaveChangesAsync();

            if (result > 0)
            {
                var entity = await DbSet.Where(x => x.Id == user.Id).FirstOrDefaultAsync();

                return(entity);
            }
            else
            {
                return(null);
            }
        }