public ActionResult GetRolePrivilegeData(string roleid)
        {
            var _draw          = Request.Form.GetValues("draw").FirstOrDefault();
            var _start         = Request.Form.GetValues("start").FirstOrDefault();
            var _length        = Request.Form.GetValues("length").FirstOrDefault();
            var _sortColumn    = Request.Form.GetValues("columns[" + Request.Form.GetValues("order[0][column]").FirstOrDefault() + "][name]").FirstOrDefault();
            var _sortColumnDir = Request.Form.GetValues("order[0][dir]").FirstOrDefault();
            var _searchValue   = Request.Form.GetValues("search[value]").FirstOrDefault();

            int _pageSize = _length != null?Convert.ToInt32(_length) : 0;

            int _skip = _start != null?Convert.ToInt32(_start) : 0;

            var _model = new RolePrivilegeModel
            {
                RoleID = long.Parse(roleid)
            };

            var request = new RolePrivilegeRequest
            {
                Draw          = _draw,
                SearchValue   = _searchValue,
                SortColumn    = _sortColumn,
                SortColumnDir = _sortColumnDir,
                PageSize      = _pageSize,
                Skip          = _skip,
                Data          = _model
            };

            var response = new RolePrivilegeHandler(_unitOfWork, _context).GetPrivilegeBasedOnOrganization(request);

            return(Json(new { data = response.Data, recordsFiltered = response.RecordsFiltered, recordsTotal = response.RecordsTotal, draw = response.Draw }, JsonRequestBehavior.AllowGet));
        }
        public JsonResult CreateRolePrivilege()
        {
            RolePrivilegeResponse response = new RolePrivilegeResponse();
            RolePrivilegeModel    _model   = new RolePrivilegeModel();

            if (Request.Form["RoleId"] != null)
            {
                _model.RoleID = Convert.ToInt64(Request.Form["RoleId"].ToString());
            }
            if (Request.Form["Privileges"] != null)
            {
                _model.PrivilegeIDs = JsonConvert.DeserializeObject <List <long> >(Request.Form["Privileges"]);
            }
            if (Session["UserLogon"] != null)
            {
                _model.Account = (AccountModel)Session["UserLogon"];
            }

            var request = new RolePrivilegeRequest
            {
                Data = _model
            };

            new RolePrivilegeValidator(_unitOfWork, _context).Validate(request, out response);
            return(Json(new { Status = response.Status, Message = response.Message }, JsonRequestBehavior.AllowGet));
        }
        /// <summary>
        /// Get list of role privilege data
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public RolePrivilegeResponse GetListData(RolePrivilegeRequest request)
        {
            var qry = _unitOfWork.RolePrivRepository.Get(x => x.RoleID == request.Data.RoleID && x.RowStatus == 0);
            RolePrivilegeModel _model = new RolePrivilegeModel();

            if (qry.Count > 0)
            {
                _model.RoleID = qry.FirstOrDefault().RoleID;
            }

            foreach (var item in qry)
            {
                _model.PrivilegeIDs.Add(item.PrivilegeID);
            }

            var response = new RolePrivilegeResponse
            {
                Entity = _model
            };

            return(response);
        }
        public ActionResult RolePrivilegeList()
        {
            RolePrivilegeModel rpmodel = new RolePrivilegeModel();

            if (Request.QueryString["roleid"] != null)
            {
                var reqOrg = new RoleRequest
                {
                    Data = new RoleModel
                    {
                        Id = Convert.ToInt64(Request.QueryString["roleid"].ToString())
                    }
                };

                var respOrg = new RoleResponse();
                respOrg          = new RoleHandler(_unitOfWork).GetDetail(reqOrg);
                rpmodel.RoleDesc = respOrg.Entity.RoleName;
                rpmodel.RoleID   = respOrg.Entity.Id;

                var _request = new RolePrivilegeRequest
                {
                    Data = new RolePrivilegeModel
                    {
                        RoleID = Convert.ToInt64(Request.QueryString["roleid"].ToString())
                    }
                };
                //get Privilege Ids for organization
                var selPrivileges = new RolePrivilegeHandler(_unitOfWork, _context).GetListData(_request);
                if (selPrivileges.Entity.PrivilegeIDs != null && selPrivileges.Entity.PrivilegeIDs.Count > 0)
                {
                    rpmodel.PrivilegeIDs = selPrivileges.Entity.PrivilegeIDs;
                }
            }

            return(View(rpmodel));
        }
Beispiel #5
0
 public AccountModelSession()
 {
     Roles      = new List <long>();
     Privileges = new RolePrivilegeModel();
     Polis      = new ClinicPoliModel();
 }
Beispiel #6
0
 public AccountModel()
 {
     Roles      = new List <long>();
     Privileges = new RolePrivilegeModel();
 }