/// <summary> /// Save the entity /// </summary> /// <param name="useTransaction">Specify if transactions should be used</param> /// <returns></returns> public int Save(bool useTransaction) { try { //If the coonection is already enlisted in a transaction use parent transaction if (IsInTransaction()) { useTransaction = false; } if (useTransaction) { BeginTransaction(); } int newId = ApplicationConstants.INT_NULL_VALUE; OnPreSave(); if (!ValidateOperation()) { throw new NotImplementedException(ApplicationMessages.EXCEPTION_IMPLEMENT_SETENTITY); } if (State == EntityState.Deleted) { DeleteChildren(); dbEntity.DeleteObject(this); } if (State == EntityState.New) { newId = dbEntity.InsertObject(this); SaveChildren(); } if (State == EntityState.Modified) { dbEntity.UpdateObject(this); SaveChildren(); } OnPostSave(); if (useTransaction) { CommitTransaction(); } return(newId); } catch (Exception exc) { if (useTransaction) { RollbackTransaction(); } throw new IndException(exc); } }
/// <summary> /// This method is used for updating an object into the database /// </summary> /// <param name="associate">This is the Associate object that holds all information that is required so that the update should be made.</param> /// <param name="dbGenericEntity">This is the Associate Entity.</param> /// <returns></returns> private int UpdateInitialBudgetTest(IInitialBudget initialBudget, DBGenericEntity dbGenericEntity) { int rowCount = dbGenericEntity.UpdateObject(initialBudget); return(rowCount); }
/// <summary> /// This method is used for updating an object into the database /// </summary> /// <param name="associate">This is the Associate object that holds all information that is required so that the update should be made.</param> /// <param name="dbGenericEntity">This is the Associate Entity.</param> /// <returns></returns> private int UpdateRevisedBudgetTest(IRevisedBudget revisedBudget, DBGenericEntity dbGenericEntity) { int rowCount = dbGenericEntity.UpdateObject(revisedBudget); return(rowCount); }