/// <summary> /// 保存群组信息 /// </summary> /// <param name="keyValue"></param> /// <param name="entity"></param> public void Save(string keyValue, IMGroupEntity entity, List <string> userIdList) { if (!string.IsNullOrEmpty(keyValue)) { entity.Modify(keyValue); this.BaseRepository().Update <IMGroupEntity>(entity); } else { IDatabase db = DbFactory.Base().BeginTrans(); try { entity.Create(); db.Insert <IMGroupEntity>(entity); foreach (string userOne in userIdList) { IMUserGroupEntity msgusergroupentity = new IMUserGroupEntity(); msgusergroupentity.GroupId = entity.GroupId; msgusergroupentity.UserId = userOne; msgusergroupentity.CreateUserId = entity.CreateUserId; msgusergroupentity.CreateUserName = entity.CreateUserName; db.Insert <IMUserGroupEntity>(msgusergroupentity); } db.Commit(); } catch (Exception) { db.Rollback(); throw; } } }
/// <summary> /// 增加一个组员到群组里面 /// </summary> /// <param name="groupId"></param> /// <param name="userId"></param> public void AddUserId(string groupId, string userId, string createUserId, string createUesrName) { IMUserGroupEntity entity = new IMUserGroupEntity(); entity.GroupId = groupId; entity.UserId = userId; entity.CreateUserId = createUserId; entity.CreateUserName = createUesrName; service.AddUserId(entity); }
/// <summary> /// 群里增加一个用户 /// </summary> /// <param name="entity"></param> public void AddUserId(IMUserGroupEntity entity) { entity.Create(); this.BaseRepository().Insert <IMUserGroupEntity>(entity); }