コード例 #1
0
        public bool AssignRoleToUser(ApplicationEntity application, UserEntity user, RolesEntity role)
        {
            try
            {
                using (IUnitOfWork uow = _UnitFactory.GetUnit(this))
                {
                    uow.BeginTransaction();
                    if (!uow.Query<AppUserRoleEntity>().Any(x => x.ApplicationId.Equals(application.IdApplication) && x.RoleId.Equals(role.Id) && x.UserId.Equals(user.Id)))
                    {
                        AppUserRoleEntity app = new AppUserRoleEntity();
                        app.ApplicationId = app.ApplicationId;
                        app.RoleId = role.Id;
                        app.UserId = user.Id;
                        uow.SaveOrUpdate(app);

                        uow.Commit();
                        return true;
                    }

                }
            }
            catch (Exception err)
            {
                //TODO:Add log here
                return false;
            }
            return true;
        }
コード例 #2
0
ファイル: RolesRepository.cs プロジェクト: arduosoft/wlog
        public bool Save(RolesEntity rolesEntity)
        {
            try
            {
                using (IUnitOfWork uow = _UnitFactory.GetUnit(this))
                {
                    uow.BeginTransaction();
                    uow.SaveOrUpdate(rolesEntity);
                    uow.Commit();
                }
                return true;
            }
            catch (Exception err)
            {
                //TODO: log here:

            }
            return false;
        }