示例#1
0
        public JsonResult save(PhanQuyenModel.SaveModel form)
        {
            Account298  nhanVien = _account298Repository.GetById(form.idNhanVien);
            IList <int> ids      = !string.IsNullOrEmpty(nhanVien.Roles)
                                       ? nhanVien.Roles.Split(',').Select(o => Convert.ToInt32(o)).ToList()
                                       : new List <int>();

            if (form.Checked)
            {
                if (!ids.Any(o => o == form.IdQuyen))
                {
                    ids.Add(form.IdQuyen);
                }
            }
            else
            {
                ids.Remove(form.IdQuyen);
            }
            nhanVien.Roles = string.Join(",", ids);
            _account298Repository.Update(nhanVien);
            _unitOfWork.Commit();

            formAuthentication.SetAuthCookie(this.HttpContext,
                                             UserAuthenticationTicketBuilder.CreateAuthenticationTicket(
                                                 nhanVien));

            return(Json(new { ok = true, JsonRequestBehavior.AllowGet }));
        }
示例#2
0
        public JsonResult saveAll(PhanQuyenModel.SaveModel form)
        {
            Account298       nhanVien = _account298Repository.GetById(form.idNhanVien);
            IList <RoleList> roles    = Roles.GetRoles();

            IList <int> ids = new List <int>();

            if (form.Checked)
            {
                ids = roles.Select(o => o.Id).ToList();
            }

            nhanVien.Roles = string.Join(",", ids);
            _account298Repository.Update(nhanVien);
            _unitOfWork.Commit();

            formAuthentication.SetAuthCookie(this.HttpContext,
                                             UserAuthenticationTicketBuilder.CreateAuthenticationTicket(
                                                 nhanVien));
            return(Json(new { ok = true, JsonRequestBehavior.AllowGet }));
        }