Ejemplo n.º 1
0
 public void TestWeixinUpdates()
 {
     var user = new UserDetail();
     user.userid = "76507593";
     user.name = "Einstein Su";
     user.department = new List<int> { 1, 2 };
     user.mobile = "13825634085";
     user.email = "*****@*****.**";
     user.enable = 1;
     user.extatrr = new UserAttribute(new[] { new WeixinAttribute { name = "爱好", value = "旅游" } });
     var result = weixin.SaveUser(user, OperateType.Update);
     Console.WriteLine(result);
     Assert.IsTrue(result.Success("updated"));
 }
Ejemplo n.º 2
0
 public static ResultBase SaveUser(this Weixin weixin, UserDetail user, OperateType operate = OperateType.Create)
 {
     string source = string.Empty;
       switch (operate)
       {
     case OperateType.Create:
       source = Resources.CreateUserUrl;
       break;
     case OperateType.Update:
       source = Resources.UpdateUserUrl;
       break;
     case OperateType.Delete:
       source = Resources.DeleteUserUrl;
       break;
       }
       string url = operate == OperateType.Delete ? string.Format(source, weixin.Token.access_token, user.userid) : string.Format(source, weixin.Token.access_token);
       if (operate == OperateType.Delete)
     return weixin.Get<ResultBase>(url);
       return weixin.Post<ResultBase>(url, user.ToString());
 }