Пример #1
0
        public int Update(string person, string Role)
        {
            T_PERSON user   = JSONHelper.FromJson <T_PERSON>(person);
            int      result = 0;

            try
            {
                var list = personRoleVM.GetListAll().Where(x => x.S_PERSONID == user.S_ID).ToList();
                if (list != null && list.Count > 0)
                {
                    list.ForEach(x => personRoleVM.Delete(x));
                }

                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.Update(user);
                result = 1;
            }
            catch (Exception ex)
            {
            }
            return(result);
        }
Пример #2
0
        public ActionResult Update(User user)
        {
            UserVM vm    = new UserVM();
            var    count = vm.Update(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));
            }
        }