コード例 #1
0
        public async Task <IdentityResult> RegisterUser(UserModel userModel)
        {
            if (string.IsNullOrEmpty(userModel.Id))
            {
                userModel.Id = Guid.NewGuid().ToString();
            }

            ApplicationUser user = new ApplicationUser
            {
                UserName       = userModel.UserName,
                Email          = userModel.Email,
                FirstName      = userModel.FirstName,
                LastName       = userModel.LastName,
                EmailConfirmed = userModel.EmailConfirmed,
                Active         = userModel.Active,
                JoinDate       = DateTime.Now,
                Id             = userModel.Id
            };

            var result = await _userManager.CreateAsync(user, userModel.Password);

            await _ctx.SaveChangesAsync();

            return(result);
        }
コード例 #2
0
        public async Task <ClientModel> CreateCliente(ClientModel clienteModel)
        {
            var oCliente = new Client
            {
                Name            = clienteModel.Name,
                Description     = clienteModel.Description,
                Secret          = Helper.GetHash(Guid.NewGuid().ToString()),
                AllowedOrigin   = clienteModel.AllowedOrigin,
                Active          = clienteModel.Active,
                ApplicationType = clienteModel.ApplicationType,
                ImgName         = clienteModel.ImgName
            };

            var result = _ctx.Clients.Add(oCliente);
            var save   = await _ctx.SaveChangesAsync();

            return(Client.GetFromEntitie(result));
        }