예제 #1
0
파일: Class1.cs 프로젝트: HennyYoffe/Bitly
 public bool CheckIfContainedHash(string hash)
 {
     using (var ctx = new BitlyContext(_connectionString))
     {
         return(ctx.Bitlies.Any(b => b.Hash == hash));
     }
 }
예제 #2
0
파일: Class1.cs 프로젝트: HennyYoffe/Bitly
 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
파일: Class1.cs 프로젝트: HennyYoffe/Bitly
 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
파일: Class1.cs 프로젝트: HennyYoffe/Bitly
 public int AddBitly(Bitly b)
 {
     using (var ctx = new BitlyContext(_connectionString))
     {
         ctx.Bitlies.Add(b);
         ctx.SaveChanges();
         return(b.Id);
     }
 }