コード例 #1
0
        public async Task <IActionResult> Putusers_roles([FromRoute] int id, [FromBody] users_roles users_roles)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != users_roles.user_id)
            {
                return(BadRequest());
            }

            _context.Entry(users_roles).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!users_rolesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #2
0
        public async Task <IActionResult> Postusers_roles([FromBody] users_roles users_roles)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.users_roles.Add(users_roles);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (users_rolesExists(users_roles.user_id))
                {
                    return(new StatusCodeResult(StatusCodes.Status409Conflict));
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("Getusers_roles", new { id = users_roles.user_id }, users_roles));
        }
コード例 #3
0
 /// <summary>
 /// 添加
 /// </summary>
 public int add(users_roles record)
 {
     using (qdbEntities myDb = new qdbEntities())
     {
         myDb.users_roles.Add(record);
         return(myDb.SaveChanges());
     }
 }
コード例 #4
0
 /// <summary>
 /// 更新
 /// </summary>
 public int updateById(users_roles record)
 {
     using (qdbEntities myDb = new qdbEntities())
     {
         myDb.users_roles.Attach(record);
         myDb.Entry(record).State = EntityState.Modified;
         return(myDb.SaveChanges());
     }
 }
コード例 #5
0
        /// <summary>
        /// 删除
        /// </summary>
        public int deleteById(int id, int roleid)
        {
            using (qdbEntities myDb = new qdbEntities())
            {
                // TODO 生成代码后需要检查一下是否找到正确的主键,这里做一个错误代码,避免直接使用
                users_roles record = new users_roles()
                {
                    USER_ID = id, ROLE_ID = roleid
                };

                myDb.users_roles.Attach(record);
                myDb.Entry(record).State = EntityState.Deleted;
                return(myDb.SaveChanges());
            }
        }
コード例 #6
0
        /// <summary>
        /// 查询
        /// </summary>
        public List <users_roles> query(users_roles record)
        {
            using (qdbEntities myDb = new qdbEntities())
            {
                IQueryable <users_roles> db = myDb.users_roles;

                if (record.USER_ID != null)

                {
                    db = db.Where <users_roles>(p => p.USER_ID.Equals(record.USER_ID));
                }

                if (record.ROLE_ID != null)

                {
                    db = db.Where <users_roles>(p => p.ROLE_ID.Equals(record.ROLE_ID));
                }

                return(db.ToList());
            }
        }
コード例 #7
0
        /// <summary>
        /// 分页查询
        /// </summary>
        public List <users_roles> queryPage(users_roles record)
        {
            int _total = 0;
            Expression <Func <users_roles, bool> > whereLambda = PredicateExtensions.True <users_roles>();

            if (record.USER_ID != null)

            {
                whereLambda.And(p => p.USER_ID.Equals(record.USER_ID));
            }

            if (record.ROLE_ID != null)

            {
                whereLambda.And(p => p.ROLE_ID.Equals(record.ROLE_ID));
            }

            return(LoadPageItems(5, 2, out _total, whereLambda, p => p.USER_ID, true));

            // return LoadPageItems(5, 2, out _total, whereLambda, p => p.ROLE_ID, true);

            // return LoadPageItems(5, 2, out _total, whereLambda, p => p.id, true);
        }
コード例 #8
0
 /// <summary>
 /// 更新
 /// </summary>
 public int updateById(users_roles record)
 {
     return(new UsersRolesDao().updateById(record));
 }
コード例 #9
0
 /// <summary>
 /// 添加
 /// </summary>
 public int add(users_roles record)
 {
     return(new UsersRolesDao().add(record));
 }
コード例 #10
0
 /// <summary>
 /// 分页查询
 /// </summary>
 public List <users_roles> queryPage(users_roles record)
 {
     return(new UsersRolesDao().queryPage(record));
 }
コード例 #11
0
 public int Del(users_roles t)
 {
     return(dao.Del(t));
 }
コード例 #12
0
 public int Change(users_roles t)
 {
     return(dao.Change(t));
 }
コード例 #13
0
 public int Add(users_roles t)
 {
     return(dao.Add(t));
 }