public static void TestAdd() { Test.Business.User UserBusiness = new Business.User(); int result = UserBusiness.Add(new Test.Model.User() { LoginName = "Hotss", Password = "******", Age = 23, CreateTime = DateTime.Now, UserSex = 1 }); Console.WriteLine(result != 0 ? "新增成功" : "新增失败"); }
public static void TestAdd() { Test.Business.User UserBusiness = new Business.User(); int result = UserBusiness.Add(new Test.Model.User() { LoginName = "Hotss", Password = "******", Age = 23, CreateTime = DateTime.Now, UserSex = 1 }); Console.WriteLine(result != 0 ? "新增成功" : "新增失败"); }
public string SaveUser(Model.User userModel) { if (!ModelState.IsValid) { return(Tools.GetValidateErrorMessag(ModelState)); } Business.User user = new Business.User(); if (!"1".Equals(Request.Querys("isadduser")) && Request.Querys("userid").IsGuid(out Guid guid)) { var oldModel = user.Get(guid); string oldJSON = null == oldModel ? "" : oldModel.ToString(); user.Update(userModel); //同步企业微信人员 if (Config.Enterprise_WeiXin_IsUse) { try { new Business.EnterpriseWeiXin.Organize().UpdateUser(userModel); } catch (Exception e) { Business.Log.Add(e); } } Business.Log.Add("修改了人员-" + userModel.Name, type: Business.Log.Type.系统管理, oldContents: oldJSON, newContents: userModel.ToString()); } else { string orgId = Request.Querys("orgid"); if (orgId.IsGuid(out Guid orgId1)) { Model.OrganizeUser organizeUser = new Model.OrganizeUser { Id = Guid.NewGuid(), IsMain = 1, OrganizeId = orgId1, UserId = userModel.Id, Sort = new Business.OrganizeUser().GetMaxSort(orgId1) }; userModel.Password = user.GetInitPassword(userModel.Id); user.Add(userModel, organizeUser); //同步企业微信人员 if (Config.Enterprise_WeiXin_IsUse) { try { new Business.EnterpriseWeiXin.Organize().AddUser(userModel); } catch (Exception e) { Business.Log.Add(e); } } Business.Log.Add("添加了人员-" + userModel.Name, userModel.ToString() + "-" + organizeUser.ToString(), Business.Log.Type.系统管理); } else { return("未找到人员对应的组织架构"); } } return("保存成功!"); }