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()); }
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)); }
/// <summary> /// 添加 /// </summary> public int add(users_roles record) { using (qdbEntities myDb = new qdbEntities()) { myDb.users_roles.Add(record); return(myDb.SaveChanges()); } }
/// <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()); } }
/// <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()); } }
/// <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()); } }
/// <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); }
/// <summary> /// 更新 /// </summary> public int updateById(users_roles record) { return(new UsersRolesDao().updateById(record)); }
/// <summary> /// 添加 /// </summary> public int add(users_roles record) { return(new UsersRolesDao().add(record)); }
/// <summary> /// 分页查询 /// </summary> public List <users_roles> queryPage(users_roles record) { return(new UsersRolesDao().queryPage(record)); }
public int Del(users_roles t) { return(dao.Del(t)); }
public int Change(users_roles t) { return(dao.Change(t)); }
public int Add(users_roles t) { return(dao.Add(t)); }