public async Task <IActionResult> PutAspnetUsers(Guid id, AspnetUsers aspnetUsers)
        {
            if (id != aspnetUsers.UserId)
            {
                return(BadRequest());
            }

            _context.Entry(aspnetUsers).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AspnetUsersExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 2
0
        public async Task <IdentityResult> CreateAsync(ApplicationUser user, CancellationToken cancellationToken)
        {
            Guid applicationId;
            var  tnx = await db.Database.BeginTransactionAsync(IsolationLevel.Serializable, cancellationToken);

            var application = await db.AspnetApplications.SingleOrDefaultAsync(c => c.ApplicationName == applicationName, cancellationToken);

            if (application == null)
            {
                applicationId = Guid.NewGuid();
                var newApplication = new AspnetApplications
                {
                    ApplicationId          = applicationId,
                    ApplicationName        = applicationName,
                    LoweredApplicationName = applicationName?.ToLowerInvariant(),
                };
                await db.AspnetApplications.AddAsync(newApplication, cancellationToken);
            }
            else
            {
                applicationId = application.ApplicationId;
            }
            Guid userId  = Guid.NewGuid();
            var  newUser = new AspnetUsers
            {
                ApplicationId    = applicationId,
                UserId           = userId,
                UserName         = user.UserName,
                LoweredUserName  = user.NormalizedUserName,
                IsAnonymous      = false,
                LastActivityDate = user.LastActivityDate,
            };
            await db.AspnetUsers.AddAsync(newUser, cancellationToken);

            var newMembership = new AspnetMembership
            {
                ApplicationId           = applicationId,
                UserId                  = userId,
                Password                = user.PasswordHash,
                PasswordSalt            = utility.GenerateSalt(),
                Email                   = user.Email,
                LoweredEmail            = user.Email?.ToLowerInvariant(),
                PasswordQuestion        = user.PasswordQuestion,
                IsApproved              = user.IsApproved,
                IsLockedOut             = user.IsLockedOut,
                CreateDate              = user.CreationDate,
                LastLoginDate           = user.LastLoginDate,
                LastPasswordChangedDate = user.LastPasswordChangedDate,
                LastLockoutDate         = user.LastLockoutDate,
            };
            await db.AspnetMembership.AddAsync(newMembership, cancellationToken);

            await db.SaveChangesAsync(cancellationToken);

            tnx.Commit();
            return(IdentityResult.Success);
        }
        public async Task <ActionResult <AspnetUsers> > PostAspnetUsers([FromBody] AspnetUsers aspnetUsers)
        {
            var aspNetApp = new AspnetApplications
            {
                ApplicationId          = Guid.NewGuid(),
                ApplicationName        = "newApplication" + DateTime.Now.ToString(),
                LoweredApplicationName = "new application" + DateTime.Now.ToString(),
                Description            = "testApplication"
            };

            aspnetUsers.Application = aspNetApp;
            _context.AspnetApplications.Add(aspNetApp);

            _context.AspnetUsers.Add(aspnetUsers);

            await _context.SaveChangesAsync();

            // return CreatedAtAction("GetAspnetUsers", new { id = aspnetUsers.UserId }, aspnetUsers);
            return(CreatedAtAction("GetAspnetUsers", new { id = aspnetUsers.UserId }, aspnetUsers.UserName));
        }
Ejemplo n.º 4
0
 public void Update(AspnetUsers obj)
 {
     HibernateTemplate.SaveOrUpdate(obj);
 }
 public async Task <AspnetUsers> GetUserId(AspnetUsers _aspnetUsers)
 {
     return(await _unitOfWork.AspnetUsersRepository.GetUserId(_aspnetUsers));
 }
        public async Task RegisterUser(AspnetUsers membership)
        {
            await _unitOfWork.AspnetUsersRepository.Add(membership);

            await _unitOfWork.SaveChangesAsync();
        }
Ejemplo n.º 7
0
 public void Update(AspnetUsers obj)
 {
     dao.Update(obj);
 }