public void Update(DelayRecord entity) { DelayRecord record = this.GetDelayRecordByID(entity.ID); if (record.BorrowAndReturnRecordInfo != null) { record.BorrowAndReturnRecordInfo = this.DataSource.BorrowAndReturnRecordInfos.Find(entity.BorrowAndReturnRecordInfo.ID); } else { record.BorrowAndReturnRecordInfo = null; } if (record.UserInfo != null) { record.UserInfo = this.DataSource.UserInfos.Find(entity.UserInfo.ID); } else { record.UserInfo = null; } record.Comments = entity.Comments; this.DataSource.SaveChanges(); }
public DelayRecord GetEntity(UserInfo user, out BorrowAndReturnRecordInfo borrowAndReturnRecordInfo) { IBorrowAndReturnRecordInfoDataProvider iBorrowAndReturnRecordInfoDataProviderdataProvider = new BorrowAndReturnRecordInfoDataProvider(); borrowAndReturnRecordInfo = iBorrowAndReturnRecordInfoDataProviderdataProvider.GetBorrowAndReturnRecordById(this.ID); borrowAndReturnRecordInfo.Forcast_Date = borrowAndReturnRecordInfo.Forcast_Date.AddDays(30); DelayRecord delayRecord = new DelayRecord(); delayRecord.BorrowAndReturnRecordInfo = borrowAndReturnRecordInfo; delayRecord.UserInfo = user; return delayRecord; }
public void Add(DelayRecord entity) { if (entity.UserInfo != null) { entity.UserInfo = this.DataSource.UserInfos.FirstOrDefault(u => u.ID == entity.UserInfo.ID); } if (entity.BorrowAndReturnRecordInfo != null) { entity.BorrowAndReturnRecordInfo = this.DataSource.BorrowAndReturnRecordInfos.FirstOrDefault(u => u.ID == entity.BorrowAndReturnRecordInfo.ID); } this.DataSource.DelayRecords.Add(entity); this.DataSource.SaveChanges(); }