Ejemplo n.º 1
0
        public JsonNetResult JsonGetUserPrivileges(string userId, string parentId)
        {
            var units        = new UnitService().GetByRootId(parentId).ToList();
            var privileges   = new UserPrivilegeService().Query(userId, parentId);
            var operateUnits = new List <UserUnitModel>();

            units.ForEach(m =>
            {
                operateUnits.Add(new UserUnitModel
                {
                    Id      = m.Id,
                    Name    = m.Name,
                    RootId  = m.RootId,
                    Operate = privileges.Any(j => j.UnitId == m.Id && j.Operate)
                });
            });
            return(JsonNet(new ResponseResult(true, new { units = operateUnits })));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取供应商关联的医院
        /// </summary>
        /// <param name="id">供应商ID</param>
        /// <returns></returns>
        public ActionResult JsonVendorHospitals(string id)
        {
            if (string.IsNullOrWhiteSpace(id))
            {
                throw new Exception("The id unit is empty.");
            }
            var hospitals            = new UnitService().QueryRoots(UnitType.Hospital).ToList();
            var selectedHospitals    = new VendorHospitalService().GetByVendor(id);
            var notSelectedHospitals = new List <UnitEntity>();
            var selectedHospital     = new List <UnitEntity>();

            hospitals.ForEach(m =>
            {
                if (selectedHospitals.All(j => j.HospitalId != m.Id))
                {
                    notSelectedHospitals.Add(m);
                }
                else
                {
                    selectedHospital.Add(m);
                }
            });
            return(JsonNet(new ResponseResult(true, new { vendorId = id, notSelectedHospitals = notSelectedHospitals, selectedHospitals = selectedHospital })));
        }