public async Task UpdateAsync(Core.Entities.User user)
        {
            var dbUser = await GetUserByEmailAsync(user.Email);

            if (!string.IsNullOrWhiteSpace(user.City))
            {
                dbUser.City = user.City;
            }

            if (!string.IsNullOrWhiteSpace(user.Name))
            {
                dbUser.Name = user.Name;
            }

            if (!string.IsNullOrWhiteSpace(user.LastName))
            {
                dbUser.LastName = user.LastName;
            }

            if (!string.IsNullOrWhiteSpace(user.Phone))
            {
                dbUser.Phone = user.Phone;
            }

            if (!string.IsNullOrWhiteSpace(user.Password))
            {
                dbUser.Password = user.Password;
            }

            await context.SaveChangesAsync();
        }
示例#2
0
 private void PopulateIdentityUser(IdentityUser identityUser, Entities.User user)
 {
     identityUser.Id            = user.UserId;
     identityUser.UserName      = user.UserName;
     identityUser.PasswordHash  = user.PasswordHash;
     identityUser.SecurityStamp = user.SecurityStamp;
 }
示例#3
0
 private void PopulateUser(Entities.User user, IdentityUser identityUser)
 {
     user.UserId        = identityUser.Id;
     user.UserName      = identityUser.UserName;
     user.PasswordHash  = identityUser.PasswordHash;
     user.SecurityStamp = identityUser.SecurityStamp;
 }
        public async Task <bool> AddAsync(Core.Entities.User user)
        {
            if (await context.Users.AnyAsync(u => u.Email == user.Email))
            {
                return(false);
            }

            await context.Users.AddAsync(user);

            await context.SaveChangesAsync();

            return(true);
        }
示例#5
0
        private IdentityUser GetIdentityUser(Entities.User user)
        {
            if (user == null)
            {
                return(null);
            }

            var identityUser = new IdentityUser();

            PopulateIdentityUser(identityUser, user);

            return(identityUser);
        }
示例#6
0
        private Entities.User GetUser(IdentityUser identityUser)
        {
            if (identityUser == null)
            {
                return(null);
            }

            var user = new Entities.User();

            PopulateUser(user, identityUser);

            return(user);
        }