public void UpdateHistory(HistoryRecord record) { if (record is null) { throw new ArgumentNullException(nameof(record)); } if (record.Id == 0) { throw new ArgumentException("Id of record is 0.", nameof(record)); } record.UpdateTime(); this.HistorySet.Update(record); this.SaveChanges(); }
public int AddHistory(HistoryRecord record) { if (record is null) { throw new ArgumentNullException(nameof(record)); } if (record.Id != 0) { throw new ArgumentException("Id of record is not 0.", nameof(record)); } record.UpdateTime(); this.HistorySet.Add(record); this.SaveChanges(); return(record.Id); }
public static void Update(HistoryRecord record) { if (record is null) { throw new ArgumentNullException(nameof(record)); } if (record.Id == 0) { throw new ArgumentException("Id of record is 0.", nameof(record)); } record.UpdateTime(); using (var db = new HistoryDb()) { db.HistorySet.Update(record); db.SaveChanges(); } }
public static int Add(HistoryRecord record) { if (record is null) { throw new ArgumentNullException(nameof(record)); } if (record.Id != 0) { throw new ArgumentException("Id of record is not 0.", nameof(record)); } record.UpdateTime(); using (var db = new HistoryDb()) { db.HistorySet.Add(record); db.SaveChanges(); return(record.Id); } }