//confirm user email
 public static void EmailConfirm(string email)
 {
     using (var context = new NeedleWork2016Context())
     {
         var user = context.AspNetUsers.Where(m => m.Email == email).FirstOrDefault();
         user.EmailConfirmed = true;
         context.SaveChanges();
     }
 }
        //User deletion by Id
        public static void DeleteUserData(string _id)
        {
            //GetAllUsers(x=>x.Email=="@mail.ru");

            using (var context = new NeedleWork2016Context())
            {
                //Linq request for delition user by Id
                var User = context.AspNetUsers.Where(c => c.Id == _id).FirstOrDefault();
                context.AspNetUsers.Remove(User);
                context.SaveChanges();
            }
        }
 //method with using predicate
 //public static List<AspNetUsers> GetAllUsers(Func<AspNetUsers, bool> predicate)
 //{
 //...
 //}
 //select data about all users
 public static List<AspNetUsers> GetAllUsers()
 {
     using (var context = new NeedleWork2016Context())
     {
         return context.AspNetUsers.Select(x=>new AspNetUsers()
         {
             Id=x.Id,
             Email=x.Email,
             FirstName=x.FirstName,
             LastName=x.LastName
         }).ToList();
     }
 }
 //check email confirmation
 public static bool IsUserConfirmedEmail(string email)
 {
     using (var context = new NeedleWork2016Context())
     {
         if (UserIsRegistered(email))
         {
             var user = context.AspNetUsers.Where(m => m.Email == email).FirstOrDefault();
             if (user.EmailConfirmed)
                 return true;
             else
                 return false;
         }
         return true;
     }
 }
 //User editing by Id
 public static void EditUser(AspNetUsers user)
 {
     using (var context = new NeedleWork2016Context())
     {
         var User = context.AspNetUsers.Where(c => c.Id == user.Id).FirstOrDefault();
         if (User != null)
         {
             User.Id = user.Id;
             User.Email = user.Email;
             User.FirstName = user.FirstName;
             User.LastName = user.LastName;
             context.SaveChanges();
         }
     }
 }
Exemplo n.º 6
0
 public UsersPDFsController(NeedleWork2016Context context)
 {
     _context = context;
 }
Exemplo n.º 7
0
 public PaletteRepository(NeedleWork2016Context context)
 {
     _context = context;
 }
 //mathod for check user registration
 public static bool UserIsRegistered(string email)
 {
     using (var context = new NeedleWork2016Context())
     {
         var user = context.AspNetUsers.Where(m => m.Email == email).FirstOrDefault();
         if (user != null)
             return true;
         else
             return false;
     }
 }
Exemplo n.º 9
0
 public RepositoryContainer(NeedleWork2016Context context)
 {
     _context = context;
 }
Exemplo n.º 10
0
 public PalettesController(NeedleWork2016Context context, IRepositoryContainer rep)
 {
     _context = context;
     _repository = rep;
 }
Exemplo n.º 11
0
 public HomeController(NeedleWork2016Context context)
 {
     _context = context;
 }
Exemplo n.º 12
0
 public FeedbacksController(NeedleWork2016Context context)
 {
     _context = context;
 }