public bool CheckIfContainedHash(string hash) { using (var ctx = new BitlyContext(_connectionString)) { return(ctx.Bitlies.Any(b => b.Hash == hash)); } }
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(); } }
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)); } }
public int AddBitly(Bitly b) { using (var ctx = new BitlyContext(_connectionString)) { ctx.Bitlies.Add(b); ctx.SaveChanges(); return(b.Id); } }