예제 #1
0
        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);
        }
예제 #2
0
        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));
        }
예제 #3
0
        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));
            }
        }