示例#1
0
 public bool CheckIfContainedHash(string hash)
 {
     using (var ctx = new BitlyContext(_connectionString))
     {
         return(ctx.Bitlies.Any(b => b.Hash == hash));
     }
 }
示例#2
0
 public void AddUser(User user, string password)
 {
     user.PasswordHash = BCrypt.Net.BCrypt.HashPassword(password);
     using (var ctx = new BitlyContext(_connectionString))
     {
         ctx.Users.Add(user);
         ctx.SaveChanges();
     }
 }
示例#3
0
 public void AddView(int bitlyid, int views)
 {
     using (var ctx = new BitlyContext(_connectionString))
     {
         ctx.Database.ExecuteSqlCommand("UPDATE Bitly SET Views = @view WHERE Id = @id",
                                        new SqlParameter("@view", views + 1),
                                        new SqlParameter("@id", bitlyid));
     }
 }
示例#4
0
 public int AddBitly(Bitly b)
 {
     using (var ctx = new BitlyContext(_connectionString))
     {
         ctx.Bitlies.Add(b);
         ctx.SaveChanges();
         return(b.Id);
     }
 }