Exemple #1
0
 public IEnumerable <Url> GetUrlsByEmail(string email)
 {
     using (var context = new UrlShortenerDataContext(_connectionString))
     {
         return(context.Urls.Where(u => u.User.EmailAddress == email).ToList());
     }
 }
Exemple #2
0
 public Url Get(string hash)
 {
     using (var context = new UrlShortenerDataContext(_connectionString))
     {
         return(context.Urls.FirstOrDefault(u => u.ShortenedHash.ToLower() == hash.ToLower()));
     }
 }
Exemple #3
0
 public void IncrementViews(int urlId)
 {
     using (var context = new UrlShortenerDataContext(_connectionString))
     {
         context.ExecuteCommand("UPDATE Urls SET Views = Views + 1 WHERE Id = {0}", urlId);
     }
 }
Exemple #4
0
 public URL Get(string shortUrl)
 {
     using (var context = new UrlShortenerDataContext(_connectionstring))
     {
         return(context.URLs.FirstOrDefault(u => u.UrlShort.ToLower() == shortUrl.ToLower()));
     }
 }
Exemple #5
0
 public URL GetUrl(string userEmail, string url)
 {
     using (var context = new UrlShortenerDataContext(_connectionstring))
     {
         return(context.URLs.FirstOrDefault(u => u.User.EmailAddress == userEmail && u.UrlOrig == url));
     }
 }
 public User GetByEmail(string email)
 {
     using (var context = new UrlShortenerDataContext(_connectionstring))
     {
         return(context.Users.FirstOrDefault(u => u.EmailAddress == email));
     }
 }
Exemple #7
0
 public void Add(Url url)
 {
     using (var context = new UrlShortenerDataContext(_connectionString))
     {
         context.Urls.InsertOnSubmit(url);
         context.SubmitChanges();
     }
 }
        public void AddUser(User user, string password)
        {
            string salt         = PasswordHelper.GenerateSalt();
            string passwordHash = PasswordHelper.HashPassword(password, salt);

            user.PasswordSalt = salt;
            user.PasswordHash = passwordHash;
            using (var context = new UrlShortenerDataContext(_connectionstring))
            {
                context.Users.InsertOnSubmit(user);
                context.SubmitChanges();
            }
        }