public MA_COUTERPARTY Create(SessionInfo sessioninfo, MA_COUTERPARTY counterparty) { using (EFUnitOfWork unitOfWork = new EFUnitOfWork()) { var checkDuplicate1 = unitOfWork.MA_COUTERPARTYRepository.All().FirstOrDefault(p => p.USERCODE == counterparty.USERCODE); if (checkDuplicate1 != null) { throw this.CreateException(new Exception(), "OPICS ID is duplicated"); } var checkDuplicate2 = unitOfWork.MA_COUTERPARTYRepository.All().FirstOrDefault(p => p.SNAME == counterparty.SNAME); if (checkDuplicate2 != null) { throw this.CreateException(new Exception(), "Short name is duplicated"); } LogBusiness logBusiness = new LogBusiness(); unitOfWork.DA_LOGGINGRepository.Add(logBusiness.CreateLogging(sessioninfo, counterparty.ID, LogEvent.COUNTERPARTY_AUDIT.ToString(), LookupFactorTables.MA_COUTERPARTY, "Counterparty", new { })); unitOfWork.MA_COUTERPARTYRepository.Add(counterparty); unitOfWork.Commit(); } return(counterparty); }
public MA_CSA_AGREEMENT UpdateCSA(SessionInfo sessioninfo, MA_CSA_AGREEMENT record) { using (EFUnitOfWork unitOfWork = new EFUnitOfWork()) { var foundData = unitOfWork.MA_CSA_AGREEMENTRepository.All().FirstOrDefault(p => p.ID == record.ID); if (foundData == null) { throw this.CreateException(new Exception(), "Data not found!"); } else { foundData.CSA_TYPE_ID = record.CSA_TYPE_ID; foundData.LOG.MODIFYBYUSERID = sessioninfo.CurrentUserId; foundData.LOG.MODIFYDATE = DateTime.Now; foundData.ISACTIVE = record.ISACTIVE; unitOfWork.Commit(); } } return(record); }
public void UOW() // should be within one transaction unit { CustomerDbObject cust = new Customer(); cust.CustomerName = "sample customer"; CustomerDbObject lead = new Lead(); lead.CustomerName = "sample lead"; IRepositoryDAL <CustomerDbObject> dal = DALFactory.CreateCustomerDAL(DALType.ADOSQL); IUnitOfWork uow = new SQLUnitOfWork(GlobalConnectionString.ConnString); dal.SetUnitWork(uow); dal.Add(cust); try { uow.Commit(); } catch (Exception) { uow.RollBack(); } IRepositoryDAL <CustomerDbObject> dal2 = DALFactory.CreateCustomerDAL(DALType.EF); IUnitOfWork uow2 = new EFUnitOfWork(GlobalConnectionString.ConnString); dal2.SetUnitWork(uow2); dal2.Add(lead); dal2.Add(cust); try { uow2.Commit(); } catch (Exception) { uow2.RollBack(); } }
public void EFUnitOfWorkTests_Create_ShouldCreateNewAirport() { // Arrange var random = new Random(); Airport newAirport = new Airport { Name = "FakeAirport_10", Latitude = random.Next(1000, 99999), Longitude = random.Next(1000, 99999) }; // Act var context = new EFUnitOfWork(_contextBuilder.Options); context.CreateSet <Airport>().Add(newAirport); context.Commit(); Airport currentCreatedRecord = context.CreateSet <Airport>().Find(newAirport.Id); // Assert Check.That(currentCreatedRecord.Name).IsEqualTo(newAirport.Name); Check.That(currentCreatedRecord.Latitude).IsEqualTo(newAirport.Latitude); Check.That(currentCreatedRecord.Longitude).IsEqualTo(newAirport.Longitude); }
/// <summary> /// 更新记录 /// </summary> /// <param name="entity"></param> /// <returns></returns> public override int Update(WarehouseEntity entity) { using (var uow = new EFUnitOfWork <WarehouseContext>(CurrentDbContext)) { //更新主表 uow.RegisterModified(entity, true); //得到现在所有的button,column,form var Pos = uow.DbContext.Position .Where(it => it.WhCode.Equals(entity.Id)); var PosDeleted = Pos .Where(it => !entity.PositionEntities.Any(t => t.Id.Equals(it.Id))); foreach (var item in PosDeleted) { uow.RegisterDeleted(item); } var PosAdd = entity.PositionEntities .Where(it => !Pos.Any(t => t.Id.Equals(it.Id))); foreach (var item in PosAdd) { uow.RegisterNew(item); } var PosModify = entity.PositionEntities .Where(it => Pos.Any(t => t.Id.Equals(it.Id))); foreach (var item in PosModify) { uow.RegisterModified(item); } return(uow.Commit()); } }
/// <summary> /// 更新记录 /// </summary> /// <param name="entity"></param> /// <returns></returns> public override int Update(DictionaryEntity entity) { using (var uow = new EFUnitOfWork <DictionaryContext>(CurrentDbContext)) { //更新主表 uow.RegisterModified(entity, true); //得到现在所有的button,column,form var Items = uow.DbContext.Detail .Where(it => it.ItemId.Equals(entity.Id)); var ItemsDeleted = Items .Where(it => !entity.DetailEntities.Any(t => t.Id.Equals(it.Id))); foreach (var item in ItemsDeleted) { uow.RegisterDeleted(item); } var ItemsAdd = entity.DetailEntities .Where(it => !Items.Any(t => t.Id.Equals(it.Id))); foreach (var item in ItemsAdd) { uow.RegisterNew(item); } var ItemsModify = entity.DetailEntities .Where(it => Items.Any(t => t.Id.Equals(it.Id))); foreach (var item in ItemsModify) { uow.RegisterModified(item); } return(uow.Commit()); } }
public MA_COUNTRY_LIMIT UpdateCountryLimit(SessionInfo sessioninfo, MA_COUNTRY_LIMIT countryLimit) { using (EFUnitOfWork unitOfWork = new EFUnitOfWork()) { if (countryLimit.EXPIRY_DATE < sessioninfo.Process.CurrentDate) { throw this.CreateException(new Exception(), "Expiry date cannot be set to past date."); } var foundData = unitOfWork.MA_COUNTRY_LIMITRepository.All().FirstOrDefault(p => p.ID == countryLimit.ID); if (foundData == null) { throw this.CreateException(new Exception(), "Data not found!"); } else { LogBusiness logBusiness = new LogBusiness(); var oldRecord = new { AMOUNT = foundData.AMOUNT.ToString("#,##0"), EXPIRE_DATE = foundData.EXPIRY_DATE }; var newRecord = new { AMOUNT = countryLimit.AMOUNT.ToString("#,##0"), EXPIRE_DATE = countryLimit.EXPIRY_DATE }; var log = logBusiness.UpdateLogging(sessioninfo, foundData.COUNTRY_ID, LimitLogEvent.COUNTRY_LIMIY_AUDIT.ToString(), LookupFactorTables.MA_COUNTRY, oldRecord, newRecord, "Country Limit"); if (log != null) { unitOfWork.DA_LOGGINGRepository.Add(log); } foundData.AMOUNT = countryLimit.AMOUNT; foundData.FLAG_CONTROL = countryLimit.FLAG_CONTROL; foundData.EXPIRY_DATE = countryLimit.EXPIRY_DATE; foundData.LOG.MODIFYBYUSERID = countryLimit.LOG.MODIFYBYUSERID; foundData.LOG.MODIFYDATE = countryLimit.LOG.MODIFYDATE; unitOfWork.Commit(); } } return(countryLimit); }
/// <summary> /// 更新记录 /// </summary> /// <param name="entity"></param> /// <returns></returns> public override int Update(CustomerEntity entity) { using (var uow = new EFUnitOfWork <CustomerContext>(CurrentDbContext)) { //更新主表 uow.RegisterModified(entity, true); //得到现在所有的button,column,form var Owner = uow.DbContext.Owner .Where(it => it.CusId.Equals(entity.Id)); var OwnerDeleted = Owner .Where(it => !entity.OwnerEntities.Any(t => t.Id.Equals(it.Id))); foreach (var item in OwnerDeleted) { uow.RegisterDeleted(item); } var OwnerAdd = entity.OwnerEntities .Where(it => !Owner.Any(t => t.Id.Equals(it.Id))); foreach (var item in OwnerAdd) { uow.RegisterNew(item); } var OwnerModify = entity.OwnerEntities .Where(it => Owner.Any(t => t.Id.Equals(it.Id))); foreach (var item in OwnerModify) { uow.RegisterModified(item); } return(uow.Commit()); } }
public MA_PORTFOLIO UpdatePorfolio(SessionInfo sessioninfo, MA_PORTFOLIO portfolio) { using (EFUnitOfWork unitOfWork = new EFUnitOfWork()) { var checkDuplicate = unitOfWork.MA_PORTFOLIORepository.GetAll().FirstOrDefault(p => p.LABEL.ToLower().Equals(portfolio.LABEL.ToLower()) && p.ID != portfolio.ID); if (checkDuplicate != null) { throw this.CreateException(new Exception(), Messages.DUPLICATE_DATA); } if (portfolio.ISDEFAULT.HasValue && portfolio.ISDEFAULT.Value) { var intCount = unitOfWork.MA_PORTFOLIORepository.GetAll().Count(p => p.ISDEFAULT == true && p.ID != portfolio.ID); if (intCount > 0) { throw this.CreateException(new Exception(), Messages.DUPLICATE_DEFAULT_DATA); } } var foundPortfolio = unitOfWork.MA_PORTFOLIORepository.All().FirstOrDefault(p => p.ID == portfolio.ID); if (foundPortfolio == null) { throw this.CreateException(new Exception(), Messages.DATA_NOT_FOUND); } else { foundPortfolio.ID = portfolio.ID; foundPortfolio.LABEL = portfolio.LABEL; foundPortfolio.ISACTIVE = portfolio.ISACTIVE; foundPortfolio.ISDEFAULT = portfolio.ISDEFAULT; unitOfWork.Commit(); } } return(portfolio); }
public MA_TEMP_CTPY_LIMIT CreateTempLimit(SessionInfo sessioninfo, MA_TEMP_CTPY_LIMIT record) { using (EFUnitOfWork unitOfWork = new EFUnitOfWork()) { if (record.EFFECTIVE_DATE < sessioninfo.Process.CurrentDate) { throw this.CreateException(new Exception(), "Effective date cannot be set to past date."); } if (record.EXPIRY_DATE < sessioninfo.Process.CurrentDate) { throw this.CreateException(new Exception(), "Expiry date cannot be set to past date."); } if (record.EXPIRY_DATE <= record.EFFECTIVE_DATE) { throw this.CreateException(new Exception(), "Expiry date must be after effective date."); } var duplicate = unitOfWork.MA_TEMP_CTPY_LIMITRepository.All().FirstOrDefault(p => p.CTPY_LIMIT_ID == record.CTPY_LIMIT_ID && p.ISACTIVE == true && p.EXPIRY_DATE >= record.EFFECTIVE_DATE); if (duplicate != null) { throw this.CreateException(new Exception(), "Duplicate temp limit info"); } LogBusiness logBusiness = new LogBusiness(); var newRecord = new { AMOUNT = record.AMOUNT, EFFECTIVE_DATE = record.EFFECTIVE_DATE, EXPIRY_DATE = record.EXPIRY_DATE }; unitOfWork.DA_LOGGINGRepository.Add(logBusiness.CreateLogging(sessioninfo, record.CTPY_LIMIT_ID, LimitLogEvent.TEMP_LIMIT_AUDIT.ToString(), LookupFactorTables.MA_TEMP_CTPY_LIMIT, "Temp Limit", newRecord)); unitOfWork.MA_TEMP_CTPY_LIMITRepository.Add(record); unitOfWork.Commit(); } return(record); }
public MA_PROCESS_DATE Update(SessionInfo sessioninfo, MA_PROCESS_DATE processdate) { using (EFUnitOfWork unitOfWork = new EFUnitOfWork()) { var found = unitOfWork.MA_PROCESS_DATERepository.All().First(); if (found == null) { throw this.CreateException(new Exception(), "Data not found!"); } else { found.NEXT_PROC_DATE = processdate.NEXT_PROC_DATE; found.PREV_PROC_DATE = processdate.PREV_PROC_DATE; found.PROC_DATE = processdate.PROC_DATE; found.FLAG_RECONCILE = processdate.FLAG_RECONCILE; found.LOG.MODIFYBYUSERID = processdate.LOG.MODIFYBYUSERID; found.LOG.MODIFYDATE = processdate.LOG.MODIFYDATE; found.FLAG_RECONCILE = processdate.FLAG_RECONCILE; unitOfWork.Commit(); } } return(processdate); }
public MA_TBMA_CONFIG UpdateTBMAConfig(SessionInfo sessioninfo, MA_TBMA_CONFIG config) { using (EFUnitOfWork unitOfWork = new EFUnitOfWork()) { var foundConfig = unitOfWork.MA_TBMA_CONFIGRepository.All().FirstOrDefault(p => p.ID == config.ID); if (foundConfig == null) { throw this.CreateException(new Exception(), Messages.DATA_NOT_FOUND); } else { foundConfig.TBMA_CAL_PASSWORD = config.TBMA_CAL_PASSWORD; foundConfig.TBMA_CAL_USERNAME = config.TBMA_CAL_USERNAME; foundConfig.TBMA_RPT_PATH = config.TBMA_RPT_PATH; foundConfig.TBMA_RPT_PREFIX = config.TBMA_RPT_PREFIX; foundConfig.TBMA_RPT_TRADERID = config.TBMA_RPT_TRADERID; unitOfWork.Commit(); } } return(config); }
/// <summary> /// 更新记录 /// </summary> /// <param name="entity"></param> /// <returns></returns> public override int Update(ModuleEntity entity) { using (var uow = new EFUnitOfWork <ModuleContext>(CurrentDbContext)) { //更新主表 uow.RegisterModified(entity, true); //得到现在所有的button,column,form var buttons = uow.DbContext.Button .Where(it => it.ModuleId.Equals(entity.Id)); var columns = uow.DbContext.Column .Where(it => it.ModuleId.Equals(entity.Id)); var forms = uow.DbContext.Form .Where(it => it.ModuleId.Equals(entity.Id)); //读取出不在当前buttons/columns/forms集合内的button/column/form,这部分作为删除对象 var btnDeleted = buttons .Where(it => !entity.ButtonEntities.Any(t => t.Id.Equals(it.Id))); var columnDeleted = columns .Where(it => !entity.ColumnEntities.Any(t => t.Id.Equals(it.Id))); var formDeleted = forms .Where(it => !entity.FormEntities.Any(t => t.Id.Equals(it.Id))); ////循环 foreach (var button in btnDeleted) { //将这部分button作为删除 uow.RegisterDeleted(button); } foreach (var column in columnDeleted) { //将这部分column作为删除 uow.RegisterDeleted(column); } foreach (var form in formDeleted) { //将这部分form作为删除 uow.RegisterDeleted(form); } //找出当前不在数据库内的buttons/columns/forms,作为新增对象 var btnAdd = entity.ButtonEntities .Where(it => !buttons.Any(t => t.Id.Equals(it.Id))); var columnAdd = entity.ColumnEntities .Where(it => !columns.Any(t => t.Id.Equals(it.Id))); var formAdd = entity.FormEntities .Where(it => !forms.Any(t => t.Id.Equals(it.Id))); //循环 foreach (var button in btnAdd) { //将这部分button作为新增 uow.RegisterNew(button); } foreach (var column in columnAdd) { //将这部分column作为新增 uow.RegisterNew(column); } foreach (var form in formAdd) { //将这部分form作为新增 uow.RegisterNew(form); } //得到更新部分 var btnModify = entity.ButtonEntities .Where(it => buttons.Any(t => t.Id.Equals(it.Id))); var columnModify = entity.ColumnEntities .Where(it => columns.Any(t => t.Id.Equals(it.Id))); var formModify = entity.FormEntities .Where(it => forms.Any(t => t.Id.Equals(it.Id))); //循环 foreach (var button in btnModify) { //将这部分button作为新增 uow.RegisterModified(button); } foreach (var column in columnModify) { //将这部分column作为新增 uow.RegisterModified(column); } foreach (var form in formModify) { //将这部分form作为新增 uow.RegisterModified(form); } return(uow.Commit()); } }
public MA_COUTERPARTY Update(SessionInfo sessioninfo, MA_COUTERPARTY counterparty) { using (EFUnitOfWork unitOfWork = new EFUnitOfWork()) { var checkDuplicate1 = unitOfWork.MA_COUTERPARTYRepository.All().FirstOrDefault(p => p.USERCODE == counterparty.USERCODE && p.ID != counterparty.ID); if (checkDuplicate1 != null) { throw this.CreateException(new Exception(), "OPICS ID is duplicated"); } var checkDuplicate2 = unitOfWork.MA_COUTERPARTYRepository.All().FirstOrDefault(p => p.SNAME == counterparty.SNAME && p.ID != counterparty.ID); if (checkDuplicate2 != null) { throw this.CreateException(new Exception(), "Short name is duplicated"); } var foundData = unitOfWork.MA_COUTERPARTYRepository.All().FirstOrDefault(p => p.ID == counterparty.ID); if (foundData == null) { throw this.CreateException(new Exception(), "Data not found!"); } else { LogBusiness logBusiness = new LogBusiness(); string strOldGroupName = ""; string strNewGroupName = ""; if (foundData.GROUP_CTPY_ID != null) { var oldGroup = unitOfWork.MA_COUTERPARTYRepository.All().FirstOrDefault(p => p.GROUP_CTPY_ID == foundData.GROUP_CTPY_ID); strOldGroupName = oldGroup != null ? oldGroup.SNAME : ""; } if (counterparty.GROUP_CTPY_ID != null) { var newGroup = unitOfWork.MA_COUTERPARTYRepository.All().FirstOrDefault(p => p.GROUP_CTPY_ID == counterparty.GROUP_CTPY_ID); strNewGroupName = newGroup != null ? newGroup.SNAME : ""; } var oldRecord = new { USERCODE = foundData.USERCODE , BUSINESS = foundData.BUSINESS , FNAME = foundData.FNAME , SNAME = foundData.SNAME , TBMA_NAME = foundData.TBMA_NAME , GROUP = strOldGroupName , OUTLOOK = foundData.OUTLOOK , RATE = foundData.RATE , ISACTIVE = foundData.ISACTIVE }; var newRecord = new { USERCODE = counterparty.USERCODE , BUSINESS = counterparty.BUSINESS , FNAME = counterparty.FNAME , SNAME = counterparty.SNAME , TBMA_NAME = counterparty.TBMA_NAME , GROUP = strNewGroupName , OUTLOOK = counterparty.OUTLOOK , RATE = counterparty.RATE , ISACTIVE = counterparty.ISACTIVE }; var log = logBusiness.UpdateLogging(sessioninfo, foundData.ID, LogEvent.COUNTERPARTY_AUDIT.ToString(), LookupFactorTables.MA_COUTERPARTY, oldRecord, newRecord); if (log != null) { unitOfWork.DA_LOGGINGRepository.Add(log); } foundData.ID = counterparty.ID; foundData.USERCODE = counterparty.USERCODE; foundData.ISACTIVE = counterparty.ISACTIVE; foundData.LOG.MODIFYBYUSERID = sessioninfo.CurrentUserId; foundData.LOG.MODIFYDATE = DateTime.Now; foundData.BUSINESS = counterparty.BUSINESS; foundData.FNAME = counterparty.FNAME; foundData.SNAME = counterparty.SNAME; foundData.OUTLOOK = counterparty.OUTLOOK; foundData.RATE = counterparty.RATE; foundData.TBMA_NAME = counterparty.TBMA_NAME; foundData.GROUP_CTPY_ID = counterparty.GROUP_CTPY_ID; foundData.COUNTRY_ID = counterparty.COUNTRY_ID; unitOfWork.Commit(); } } return(counterparty); }
// DELETE api/TimeTable/5 public void Delete(int id) { uow.TimeTables.Remove(uow.TimeTables.GetById(id)); uow.Commit(); }
public void Save() { _unitOfWork.Commit(); }
/// <summary> /// 更新记录 /// </summary> /// <param name="entity"></param> /// <returns></returns> public override int Update(RoleEntity entity) { using (var uow = new EFUnitOfWork <RoleContext>(CurrentDbContext)) { //更新主表 uow.RegisterModified(entity, true); //得到现在所有的button,column,Moduls var buttons = uow.DbContext.RoleButton .Where(it => it.RoleId.Equals(entity.Id)); var columns = uow.DbContext.RoleColumn .Where(it => it.RoleId.Equals(entity.Id)); var moduls = uow.DbContext.RoleModule .Where(it => it.RoleId.Equals(entity.Id)); //读取出不在当前buttons/columns/Moduls集合内的button/column/Moduls,这部分作为删除对象 var btnDeleted = buttons .Where(it => !entity.Buttons.Any(t => t.Id.Equals(it.Id))); var columnDeleted = columns .Where(it => !entity.Columns.Any(t => t.Id.Equals(it.Id))); var modulDeleted = moduls .Where(it => !entity.Modules.Any(t => t.Id.Equals(it.Id))); ////循环 foreach (var button in btnDeleted) { //将这部分button作为删除 uow.RegisterDeleted(button); } foreach (var column in columnDeleted) { //将这部分column作为删除 uow.RegisterDeleted(column); } foreach (var modul in modulDeleted) { //将这部分modul作为删除 uow.RegisterDeleted(modul); } //找出当前不在数据库内的buttons/columns/moduls,作为新增对象 var btnAdd = entity.Buttons .Where(it => !buttons.Any(t => t.Id.Equals(it.Id))); var columnAdd = entity.Columns .Where(it => !columns.Any(t => t.Id.Equals(it.Id))); var modulAdd = entity.Modules .Where(it => !moduls.Any(t => t.Id.Equals(it.Id))); //循环 foreach (var button in btnAdd) { //将这部分button作为新增 uow.RegisterNew(button); } foreach (var column in columnAdd) { //将这部分column作为新增 uow.RegisterNew(column); } foreach (var modul in modulAdd) { //将这部分modul作为新增 uow.RegisterNew(modul); } //得到更新部分 var btnModify = entity.Buttons .Where(it => buttons.Any(t => t.Id.Equals(it.Id))); var columnModify = entity.Columns .Where(it => columns.Any(t => t.Id.Equals(it.Id))); var formModify = entity.Modules .Where(it => moduls.Any(t => t.Id.Equals(it.Id))); //循环 foreach (var button in btnModify) { //将这部分button作为新增 uow.RegisterModified(button); } foreach (var column in columnModify) { //将这部分column作为新增 uow.RegisterModified(column); } foreach (var modul in formModify) { //将这部分modul作为新增 uow.RegisterModified(modul); } return(uow.Commit()); } }
// DELETE api/study/5 public void Delete(int id) { uow.Studies.Remove(uow.Studies.GetById(id)); uow.Commit(); }
public MA_INSTRUMENT Update(SessionInfo sessioninfo, MA_INSTRUMENT instrument, ProductCode product) { using (EFUnitOfWork unitOfWork = new EFUnitOfWork()) { var checkDuplicate = unitOfWork.MA_INSTRUMENTRepository.GetAllByProductCode(product.ToString()).FirstOrDefault(p => p.LABEL == instrument.LABEL && p.ID != instrument.ID); if (checkDuplicate != null) { throw this.CreateException(new Exception(), "Label is duplicated"); } var foundData = unitOfWork.MA_INSTRUMENTRepository.GetAll().FirstOrDefault(p => p.ID == instrument.ID); if (foundData == null) { throw this.CreateException(new Exception(), "Data not found!"); } else { if (product == ProductCode.BOND) { LogBusiness logBusiness = new LogBusiness(); var oldRecord = new { ISACTIVE = foundData.ISACTIVE, CAL_METHOD = foundData.CAL_METHOD, COUPON = foundData.COUPON, COUPON_FREQ_TYPE = foundData.MA_FREQ_TYPE != null ?foundData.MA_PRODUCT.LABEL:string.Empty, FLAG_FIXED = foundData.FLAG_FIXED, INS_MKT = foundData.INS_MKT, ISSUER = foundData.ISSUER, LABEL = foundData.LABEL, LOT_SIZE = foundData.LOT_SIZE, MATURITY_DATE = foundData.MATURITY_DATE, PRODUCT = foundData.MA_PRODUCT != null ? foundData.MA_PRODUCT.LABEL:string.Empty, CURRENCY = foundData.MA_CURRENCY != null ? foundData.MA_CURRENCY.LABEL:string.Empty }; var newRecord = new { ISACTIVE = instrument.ISACTIVE, CAL_METHOD = instrument.CAL_METHOD, COUPON = instrument.COUPON, COUPON_FREQ_TYPE = unitOfWork.MA_FREQ_TYPERepository.All().FirstOrDefault(f => f.ID == instrument.COUPON_FREQ_TYPE_ID).LABEL, FLAG_FIXED = instrument.FLAG_FIXED, INS_MKT = instrument.INS_MKT, ISSUER = instrument.ISSUER, LABEL = instrument.LABEL, LOT_SIZE = instrument.LOT_SIZE, MATURITY_DATE = instrument.MATURITY_DATE, PRODUCT = unitOfWork.MA_PRODUCTRepository.All().FirstOrDefault(p => p.ID == instrument.PRODUCT_ID).LABEL, CURRENCY = unitOfWork.MA_CURRENCYRepository.All().FirstOrDefault(c => c.ID == instrument.CURRENCY_ID1).LABEL, }; var log = logBusiness.UpdateLogging(sessioninfo, foundData.ID, LogEvent.INSTRUMENT_AUDIT.ToString(), LookupFactorTables.MA_INSTRUMENT, oldRecord, newRecord); if (log != null) { unitOfWork.DA_LOGGINGRepository.Add(log); } } foundData.ID = instrument.ID; foundData.ISACTIVE = instrument.ISACTIVE; foundData.LOG.MODIFYBYUSERID = sessioninfo.CurrentUserId; foundData.LOG.MODIFYDATE = DateTime.Now; foundData.CAL_METHOD = instrument.CAL_METHOD; foundData.COUPON = instrument.COUPON; foundData.COUPON_FREQ_TYPE_ID = instrument.COUPON_FREQ_TYPE_ID; foundData.FLAG_FIXED = instrument.FLAG_FIXED; foundData.INS_MKT = instrument.INS_MKT; foundData.ISSUER = instrument.ISSUER; foundData.LABEL = instrument.LABEL; foundData.LOT_SIZE = instrument.LOT_SIZE; foundData.MATURITY_DATE = instrument.MATURITY_DATE; foundData.PRODUCT_ID = instrument.PRODUCT_ID; foundData.CURRENCY_ID1 = instrument.CURRENCY_ID1; foundData.CURRENCY_ID2 = instrument.CURRENCY_ID2; unitOfWork.Commit(); } } return(instrument); }