示例#1
0
        public dynamic GetUserAccess(int userId, string groupname)
        {
            try
            {
                int totalmenu = _userMenuService.GetQueryable().Count();
                var q         = _userAccessService.GetQueryableObjectsByUserAccountId(userId).Include("UserMenu");

                if (q.Count() < totalmenu)
                {
                    _userAccessService.CreateDefaultAccess(userId, _userMenuService, _userAccountService);
                }

                var model = (from m in q
                             select new
                {
                    m.Id,
                    m.UserMenu.Name,
                    m.UserMenu.GroupName,
                    m.AllowView,
                    m.AllowCreate,
                    m.AllowEdit,
                    m.AllowDelete,
                    m.AllowUndelete,
                    m.AllowPrint,
                    m.AllowPaid,
                    m.AllowConfirm,
                    m.AllowReconcile,
                    m.AllowUnconfirm,
                    m.AllowUnpaid,
                    m.AllowUnreconcile,
                    m.AllowSpecialPricing,
                }).ToList();
                return(Json(new
                {
                    model
                }, JsonRequestBehavior.AllowGet));
            }

            catch (Exception ex)
            {
                LOG.Error("GetUserAccessAccountingList", ex);
                Dictionary <string, string> Errors = new Dictionary <string, string>();
                Errors.Add("Generic", "Error " + ex);

                return(Json(new
                {
                    Errors
                }, JsonRequestBehavior.AllowGet));
            }
        }