public ActionResult <MemberGroupDisplay> PostSave(MemberGroupSave saveModel) { var id = int.Parse(saveModel.Id.ToString(), CultureInfo.InvariantCulture); IMemberGroup memberGroup = id > 0 ? _memberGroupService.GetById(id) : new MemberGroup(); if (memberGroup == null) { return(NotFound()); } if (IsMemberGroupNameUnique(memberGroup.Id, memberGroup.Name, saveModel.Name)) { memberGroup.Name = saveModel.Name; _memberGroupService.Save(memberGroup); MemberGroupDisplay display = _umbracoMapper.Map <IMemberGroup, MemberGroupDisplay>(memberGroup); display.AddSuccessNotification( _localizedTextService.Localize("speechBubbles", "memberGroupSavedHeader"), string.Empty); return(display); } else { MemberGroupDisplay display = _umbracoMapper.Map <IMemberGroup, MemberGroupDisplay>(memberGroup); display.AddErrorNotification( _localizedTextService.Localize("speechBubbles", "memberGroupNameDuplicate"), string.Empty); return(display); } }
public SecurityGroup CreateOrFindGroup(string groupNamePrefix, string suggestedGroupName, IEnumerable <string> noiseWords) { var groupName = _routeGenerator.GenerateRoute(groupNamePrefix, suggestedGroupName, noiseWords); IMemberGroup group; do { group = _memberGroupService.GetByName(groupName); if (group == null) { group = new MemberGroup { Name = groupName }; _memberGroupService.Save(group); break; } else { groupName = _routeGenerator.IncrementRoute(groupName); } }while (group != null); return(new SecurityGroup { Key = group.Key, Name = group.Name }); }
public Task CreateAsync(T role) { if (role == null) { throw new ArgumentNullException("role"); } var memberGroup = new MemberGroup { Name = role.Name }; _memberGroupService.Save(memberGroup); role.Id = memberGroup.Id; return(Task.FromResult(0)); }
/// <inheritdoc /> public Task <IdentityResult> CreateAsync(UmbracoIdentityRole role, CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfDisposed(); if (role == null) { throw new ArgumentNullException(nameof(role)); } var memberGroup = new MemberGroup { Name = role.Name }; _memberGroupService.Save(memberGroup); role.Id = memberGroup.Id.ToString(); return(Task.FromResult(IdentityResult.Success)); }
public virtual int Create(string name) { if (string.IsNullOrWhiteSpace(name)) { return(int.MinValue); } var group = _memberGroupService.GetByName(name); if (group != null) { return(group.Id); } _memberGroupService.Save(new MemberGroup { Name = name }); group = _memberGroupService.GetByName(name); ClearCache(); return(group.Id); }
public IMemberGroup CreateMemberGroup(string name) { var group = new MemberGroup { Name = name }; //group.AdditionalData.Add("test1", 123); //group.AdditionalData.Add("test2", "hello"); _memberGroupService.Save(group); return(group); }