示例#1
0
 private EMUser ConvertTo(EMUserViewModel entity)
 {
     EMUser model = null;
     if (entity != null)
     {
         IUserService userService = new UserService();
         EMUser eMUser = userService.GetUser(entity.UserCode);
         model = new EMUser();
         model.UserCode = entity.UserCode;
         model.UserName = entity.UserName;
         model.IsRegisterUser = entity.IsRegisterUser;
         model.PassWord = entity.PassWord;
         model.RealName = entity.RealName;
         model.Mobile = entity.Mobile;
         model.Tenant = new EMTenant() { TenantCode = entity.TenantCode };
         model.LastLoginTime = entity.LastLoginTime;
         if (eMUser != null)
             model.CreateTime = eMUser.CreateTime;
         model.UserGroupID = entity.UserGroupID;
     }
     return model;
 }
示例#2
0
 public ResultContent AddUser(EMUserViewModel userViewModel)
 {
     ResultContent rc = new ResultContent();
     try
     {
         IUserService userService = new UserService();
         bool bl = userService.ExistsUser(userViewModel.UserName);
         if (bl)
         {
             rc.Result = false;
             rc.Message = "用户名已存在!";
         }
         else
         {
             IdentityNoService identityNoServ = new IdentityNoService();
             userViewModel.UserCode = identityNoServ.GetUserSerialNo();
             userViewModel.CreateTime = DateTime.Now;
             EMUser entity = ConvertHelper.ConvertObj<EMUserViewModel, EMUser>(userViewModel);
             entity.Tenant = new EMTenant() { TenantCode = userViewModel.TenantCode };
             userService.Add(entity);
             rc.Result = true;
             rc.Message = "添加成功!";
         }
     }
     catch (Exception ex)
     {
         Logger.Error(ex.Message, ex);
         rc.Result = false;
         rc.Message = ex.Message;
     }
     return rc;
 }