public APIReturn Delete_delete(ulong?Id) { int affrows = Userclaim.Delete(Id); if (affrows > 0) { return(new APIReturn(0, string.Format("删除成功,影响行数:{0}", affrows))); } return(new APIReturn(99, "失败")); }
public IActionResult GetAll() { var userIdClaim = HttpContext.User.Claims.Where(x => x.Type == "userid").SingleOrDefault(); User _user = Userclaim.getUserById(userIdClaim); _logger.LogInformation("Logged in user : " + _user.Name); var users = _userService.GetAll(); return(Ok(users)); }
public APIReturn Get_item(ulong?Id) { UserclaimInfo item = Userclaim.GetItem(Id); if (item == null) { return(new APIReturn(98, "记录不存在,或者没有权限")); } return(new APIReturn(0, "成功", "item", item.ToBson())); }
public APIReturn Post_insert([FromForm] ulong?Users_id, [FromForm] string Type, [FromForm] string Value) { UserclaimInfo item = new UserclaimInfo(); item.Users_id = Users_id; item.Create_time = DateTime.Now; item.Type = Type; item.Value = Value; item = Userclaim.Insert(item); return(new APIReturn(0, "成功", "item", item.ToBson())); }
public APIReturn Put_update(ulong?Id, [FromForm] ulong?Users_id, [FromForm] string Type, [FromForm] string Value) { UserclaimInfo item = new UserclaimInfo(); item.Id = Id; item.Users_id = Users_id; item.Create_time = DateTime.Now; item.Type = Type; item.Value = Value; int affrows = Userclaim.Update(item); if (affrows > 0) { return(new APIReturn(0, "成功")); } return(new APIReturn(99, "失败")); }
public ActionResult EditUserMenu(UserclaimViewModel model) { try { if (ModelState.IsValid) { var checkRole = _dbContext.tbl_Roles.Where(w => w.RoleId == model.RoleId).FirstOrDefault(); if (checkRole != null) { _dbContext.tbl_Userclaim.RemoveRange(_dbContext.tbl_Userclaim.Where(w => w.RoleId == model.RoleId)); _dbContext.SaveChanges(); foreach (var roleMenu in model.Menus) { if (roleMenu.Ischecked) { Userclaim claim = new Userclaim { MenuId = roleMenu.MenuId, RoleId = model.RoleId, IsActive = true, Columns = "", CreatedBy = _userId, CreatedDate = DateTime.Now, }; _dbContext.tbl_Userclaim.Add(claim); _dbContext.SaveChanges(); } } ViewBag.SuccessMessage = "Detail added successfully"; } else { return(RedirectToAction("UserMenuList", "UserSetting")); } } } catch (Exception ex) { return(RedirectToAction("UserMenuList", "UserSetting")); } return(View(model)); }
public virtual Task AddClaimsAsync(UsersInfo user, IEnumerable <Claim> claims, CancellationToken cancellationToken = default(CancellationToken)) { ThrowIfDisposed(); if (user == null) { throw new ArgumentNullException(nameof(user)); } if (claims == null) { throw new ArgumentNullException(nameof(claims)); } foreach (var claim in claims) { Userclaim.Insert(new UserclaimInfo { Create_time = DateTime.Now, Type = claim.Type, Value = claim.Value, Users_id = user.Id }); } //System.Security.Authentication.ExtendedProtection.se return(Task.FromResult(false)); }