public int PersonAdd(string person, string Role) { T_PERSON user = JSONHelper.FromJson <T_PERSON>(person); int result = 0; try { if (!string.IsNullOrEmpty(Role)) { var arr = Role.Split(','); foreach (var item in arr) { T_Person_Role _personRole = new T_Person_Role(); _personRole.S_Id = Common.Utilities.UniqueNumber.GuidNumber(); _personRole.S_PERSONID = user.S_POLICENUM; _personRole.S_ROLE_ID = item; _personRole.D_UPDATETIME = DateTime.Now; personRoleVM.Add(_personRole); } } result = userVM.Add(user); result = 1; } catch (Exception ex) { } return(result); }
public async Task <IActionResult> Index() { var claimsIdentity = (ClaimsIdentity)this.User.Identity; var claim = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier); if (claim.Value == null) { return(BadRequest()); } var users = _repo.User.FindAll().ToList(); var usersInModel = _mapper.Map <List <User> >(users); foreach (var user in usersInModel) { var userRoles = await _userManager.GetRolesAsync(user); UserVM.Add(new UserViewModel() { User = user, Roles = userRoles.ToList() }); } return(View(UserVM)); }
public ActionResult Add(User user) { UserVM vm = new UserVM(); var count = vm.Add(user); if (count == 1) { var rv = new { success = true }; return(Json(rv, JsonRequestBehavior.AllowGet)); } else { var rv = new { success = false }; return(Json(rv, JsonRequestBehavior.AllowGet)); } }