public override void Save(BXUser user, BXSqlTransaction tran) { forumUser = forumUser ?? BXForumUser.GetById(user.UserId, BXTextEncoder.EmptyTextEncoder); if (forumUser == null) { forumUser = new BXForumUser(BXTextEncoder.EmptyTextEncoder); forumUser.Id = user.UserId; } forumUser.Signature = Signature.Text; forumUser.OwnPostNotification = OwnPostNotification.Checked; forumUser.Save(tran != null ? tran.Connection : null, tran); }
public override void Save(BXUser user, BXSqlTransaction tran) { if (blogUser == null) { blogUser = BXBlogUser.GetList( new BXFilter(new BXFilterItem(BXBlogUser.Fields.Id, BXSqlFilterOperators.Equal, user.UserId)), null, null, new BXQueryParams { Transaction = tran }, BXTextEncoder.EmptyTextEncoder ) .FirstOrDefault(); } if (blogUser == null) { blogUser = new BXBlogUser(BXTextEncoder.EmptyTextEncoder); blogUser.Id = user.UserId; } var groups = Request.Form.GetValues(UniqueID + "$group"); var blogs = Request.Form.GetValues(UniqueID + "$blog"); var autos = Request.Form.GetValues(UniqueID + "$auto"); var newBindings = new List<BindingInfo>(); if (groups != null && groups.Length > 0) { for (int i = 0; i < groups.Length; i++) { int id; if (!int.TryParse(groups[i], out id) || id <= 0) continue; var group = BXBlogUserGroup.GetList( new BXFilter(new BXFilterItem(BXBlogUserGroup.Fields.Id, BXSqlFilterOperators.Equal, id)), null, new BXSelectAdd(BXBlogUserGroup.Fields.Blog.Name), new BXQueryParams { AllowPaging = true, PagingStartIndex = 0, PagingRecordCount = 1, Transaction = tran }, BXTextEncoder.EmptyTextEncoder ) .FirstOrDefault(); if (group == null) continue; if (group.BlogId <= 0 || !Blogs.Exists(x => x.Id == group.BlogId) || group.Type != BXBlogUserGroupType.UserDefined) { var b = bindings.Find(x => x.BlogGroup.Id == id); if (b != null && !newBindings.Exists(x => x.BlogGroup.Id == group.Id)) newBindings.Add(new BindingInfo { BlogGroup = group, Editable = false, IsAuto = b.IsAuto }); continue; } if (!newBindings.Exists(x => x.BlogGroup.Id == group.Id)) { var b = bindings.Find(x => x.BlogGroup.Id == id); newBindings.Add(new BindingInfo { BlogGroup = group, Editable = true, IsAuto = b != null && b.IsAuto && autos[i] == "true" }); } } } bindings = newBindings; blogUser.UserGroups.Clear(); blogUser.UserGroups.AddRange(bindings.ConvertAll(x => new BXBlogUser2Group(x.BlogGroup.Id))); blogUser.Save(tran != null ? tran.Connection : null, tran); }