Ejemplo n.º 1
0
        ///<Summary>
        ///SaveNew
        ///This method persists a new IdentityUserRole record to the store
        ///</Summary>
        ///<returns>
        ///void
        ///</returns>
        ///<parameters>
        ///
        ///</parameters>
        public virtual void SaveNew()
        {
            Doing(this);
            IDAOIdentityUserRole daoIdentityUserRole = _iIdentityUserRoleRepository.New();

            RegisterDataObject(_iIdentityUserRoleRepository, _iIdentityUserRoleRepository.BaseData(daoIdentityUserRole));
            BeginTransaction(_iIdentityUserRoleRepository, "savenewBOIdentityUserRole");
            try
            {
                daoIdentityUserRole.UserId = _userId;
                daoIdentityUserRole.RoleId = _roleId;
                _iIdentityUserRoleRepository.Insert(daoIdentityUserRole);
                CommitTransaction(_iIdentityUserRoleRepository);
                Done(this);

                _userId  = daoIdentityUserRole.UserId;
                _roleId  = daoIdentityUserRole.RoleId;
                _isDirty = false;
            }
            catch (Exception ex)
            {
                Failed(this, ex);
                RollbackTransaction(_iIdentityUserRoleRepository, "savenewBOIdentityUserRole");
                Handle(this, ex);
            }
        }
Ejemplo n.º 2
0
        ///<Summary>
        ///AddIdentityUserRole
        ///This method persists a BOIdentityUserRole object to the database collection
        ///</Summary>
        ///<returns>
        ///void
        ///</returns>
        ///<parameters>
        ///BOIdentityUserRole
        ///</parameters>
        public virtual void AddIdentityUserRole(IBOIdentityUserRole boIdentityUserRole)
        {
            Doing(this);
            IDAOIdentityUserRole daoIdentityUserRole = _iIdentityUserRoleRepository.New();

            RegisterDataObject(_iIdentityUserRoleRepository, _iIdentityUserRoleRepository.BaseData(daoIdentityUserRole));
            BeginTransaction(_iIdentityUserRoleRepository, "addIdentityUserRole");
            try
            {
                daoIdentityUserRole.RoleId = boIdentityUserRole.RoleId;
                daoIdentityUserRole.UserId = _userId.Value;
                _iIdentityUserRoleRepository.Insert(daoIdentityUserRole);
                CommitTransaction(_iIdentityUserRoleRepository);
                Done(this);

                /*pick up any primary keys, computed values etc*/
                boIdentityUserRole = new BOIdentityUserRole(daoIdentityUserRole);
                if (_boIdentityUserRoleCollection != null)
                {
                    _boIdentityUserRoleCollection.Add(boIdentityUserRole);
                }
            }
            catch (Exception ex)
            {
                Failed(this, ex);
                RollbackTransaction(_iIdentityUserRoleRepository, "addIdentityUserRole");
                Handle(this, ex);
            }
        }