public void UpdateViews(int id, int views) { try { using (var ctx = new DatabaseContext()) { ctx.Database.ExecuteSqlCommand("UPDATE works SET views = {1} where id = {0}", id, views); ctx.SaveChanges(); } } catch (Exception ex) { } }
public bool UpdatePassword(int id, string password) { bool updated = false; try { using (var ctx = new DatabaseContext()) { ctx.Database.ExecuteSqlCommand("UPDATE users SET password = {1} where id = {0}", id, password); ctx.SaveChanges(); updated = true; } } catch(Exception ex) { updated = false; } return updated; }