public virtual bool Save(int ledgerId, TEntity entity, IDbConnection con, IDbTransaction tran)
        {
            if (ledgerId <= 0)
            {
                return(false);
            }

            if (entity == null)
            {
                return(true);
            }

            entity.LedgerId = ledgerId;
            bool found = con.Any <TEntity>(b => b.LedgerId == ledgerId);

            // Insert
            if (!found)
            {
                // No data, skip
                if (entity.IsEmpty())
                {
                    return(true);
                }

                // Insert
                int?addressId = _addressRepository.Save(entity.Address, con, tran);
                int?contactId = _contactRepository.Save(entity.Contact, con, tran);
                entity.AddressId = addressId;
                entity.ContactId = contactId;
                int entityId = Convert.ToInt32(con.Insert(entity, tran));
                return(entityId > 0);
            }
            // Update/Delete
            else
            {
                // Delete
                if (entity.IsEmpty())
                {
                    return(Remove(ledgerId, con, tran));
                }

                // Update
                int?addressId = _addressRepository.Save(entity.Address, con, tran);
                int?contactId = _contactRepository.Save(entity.Contact, con, tran);
                entity.AddressId = addressId;
                entity.ContactId = contactId;
                return(con.Update(entity, tran));
            }
        }