Exemplo n.º 1
0
 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();
 }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
 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();
     }
 }
Exemplo n.º 4
0
        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);
            }
        }