Пример #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();
 }
Пример #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);
 }
Пример #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();
     }
 }
Пример #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);
            }
        }