protected static void AddLink(string link)
 {
     using (UserDBContext db = new UserDBContext())
     {
         db.Add(new Links(link));
         db.SaveChanges();
     }
 }
 public static void Register
     (string nickname, string email, string password)
 {
     using (UserDBContext db = new UserDBContext())
     {
         db.Add(new UserInfo(email, nickname, password));
         db.SaveChanges();
     }
 }
 public static bool IsValidAuthorization(string nickname, string pass)
 {
     using (UserDBContext db = new UserDBContext())
     {
         var check = db.Users
                     .ToList()
                     .FirstOrDefault
                         (a => a.NickName == nickname);
         if (check == default(UserInfo))
         {
             return(false);
         }
         if (check.Password == pass)
         {
             check.IsLoggedIn = true;
         }
         db.SaveChanges();
         return(check.IsLoggedIn);
     }
 }
 public UserInfo(string mail, string nick, string pass)
 {
     EMail    = mail;
     NickName = nick;
     Password = pass;
     using (UserDBContext db = new UserDBContext())
     {
         var links = db.LinkLibrary.ToList();
         var users = db.Users.ToList();
         if (users.Count == 0)
         {
             foreach (var link in links)
             {
                 link.NickName = NickName;
             }
         }
         else
         {
             int linksPerUser = links.Count / users.Count;
             int userCount    = 0;
             while (linksPerUser > 0)
             {
                 links
                 .Where(a => a.NickName == users[userCount].NickName)
                 .FirstOrDefault()
                 .NickName = NickName;
                 userCount++;
                 linksPerUser--;
                 if (userCount == users.Count)
                 {
                     userCount = 0;
                 }
             }
         }
         db.SaveChanges();
     }
 }