public ResultContent AddUserIncludeVehicle(EMUserGroupOrViewModel 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 = ConvertTo(userViewModel);
             entity.Tenant = new EMTenant() { TenantCode = entity.TenantCode };
             userService.Add(entity);
             if (userViewModel.UserGroupID == null)
             {
                 var query = from f in userViewModel.VehicleCodeList select new EMVehicleOfUser { UserCode = entity.UserCode, VehicleCode = f };
                 List<EMVehicleOfUser> vosList = query.ToList();
                 IEMVehicleOfUserService vosSerive = new EMVehicleOfUserService();
                 vosSerive.Insert(vosList);
             }
             rc.Result = true;
             rc.Message = "添加成功!";
         }
     }
     catch (Exception ex)
     {
         Logger.Error(ex.Message, ex);
         rc.Result = false;
         rc.Message = ex.Message;
     }
     return rc;
 }
 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;
 }