public static string deletevideo(int cpId) { try { using (var db = new hoccattocEntities()) { var cp = new video() { id = cpId }; db.Entry(cp).State = EntityState.Deleted; db.SaveChanges(); } return(string.Empty); } catch (Exception ex) { return("Thất bại: " + ex.Message); } }
public static string addUpdateVideo(video cp) { try { using (var db = new hoccattocEntities()) { if (cp.id == 0) { db.videos.Add(cp); } else { db.Entry(cp).State = EntityState.Modified; } db.SaveChanges(); } return(cp.id.ToString()); } catch (Exception ex) { return("0"); } }