Пример #1
0
 public async Task CreateAccount(User user)
 {
     using (var context = new UserEntities())
     {
         context.Users.Add(user);
         await context.SaveChangesAsync();
     }
 }
Пример #2
0
        public async Task <User> SetVerificationStatus(int userId, bool verificationStatus)
        {
            using (var context = new UserEntities())
            {
                var user = await context.Users.FirstOrDefaultAsync(x => x.UserId == userId);

                if (user == null)
                {
                    throw new NotFoundException("User not found");
                }
                user.Email_Verified = verificationStatus ? 1 : 0;
                await context.SaveChangesAsync();

                return(user);
            }
        }
Пример #3
0
        public async Task <User> UpdateAccount(string userId, string name, string email)
        {
            using (var context = new UserEntities())
            {
                int.TryParse(userId, out var id);
                var user = await context.Users.FirstOrDefaultAsync(x => x.UserId == id);

                if (user == null)
                {
                    throw new NotFoundException("User not fount");
                }

                user.Email = email;
                user.Name  = name;

                await context.SaveChangesAsync();

                return(user);
            }
        }