public void Create(Work work) { work.WorkID = string.IsNullOrWhiteSpace(work.WorkID) ? _untity.AutoProduceID(_db.Work, "WorkID") : work.WorkID; work.CreateTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); _db.Add(work); _db.SaveChanges(); }
public void AutoProduceIDTest() { var newID = _untity.AutoProduceID(_db.Work, "WorkID"); var newIDTest = (Convert.ToInt32(_db.Work.ToList().LastOrDefault().WorkID) + 1).ToString(); newIDTest = newIDTest.PadLeft(10, '0'); Assert.AreEqual(newIDTest, newID); }