Beispiel #1
0
 public GetMenuResponse GetMenuByUrl(GetMenuRequestByUrl request)
 {
     try
     {
         var response = new GetMenuResponse();
         var menu     = DataContext.Menus.AsNoTracking().Include(x => x.RoleGroups).FirstOrDefault(x => x.RoleGroups.Select(y => y.Id).Contains(request.RoleId) && x.Url.Contains(request.Url));
         if (menu != null)
         {
             response           = menu.MapTo <GetMenuResponse>();
             response.IsSuccess = true;
         }
         else
         {
             response.IsSuccess = false;
             response.Message   = "No Menu Found";
         }
         return(response);
     }
     catch (System.InvalidOperationException x)
     {
         return(new GetMenuResponse
         {
             IsSuccess = false,
             Message = x.Message
         });
     }
 }
Beispiel #2
0
        public void GetMenuTest()
        {
            TokenManager  manger = new TokenManager();
            TokenEntity   entiy  = manger.GetToken("0");
            IWeiXinClient client = new DefaultWeiXinClient();

            client.Token = entiy;
            GetMenuRequest request = new GetMenuRequest();

            request.AgentId = entiy.AgentID;
            GetMenuResponse response = client.Execute <GetMenuResponse>(request);

            Assert.AreEqual(0, response.ErrCode);
        }