public int Update(AGSGroupEntity group) { var selected = _roleManager.FindByIdAsync(group.Id).Result; if (selected == null) { return(0); } // update the group info MapAGSGroupEntityToEFApplicationRole(group, selected); _ = _roleManager.UpdateAsync(selected).Result; // remove all the existing associated function claims var existingClaimIds = this.GetFunctionClaimIdsByGroupId(group.Id); if (existingClaimIds != null) { foreach (var existingClaimId in existingClaimIds) { this.RemoveFunctionClaimFromGroup(group.Id, existingClaimId); } } // add new associated function claims to the group if (group.FunctionClaimIds != null) { foreach (var functionClaimId in group.FunctionClaimIds) { this.AddFunctionClaimToGroup(group.Id, functionClaimId); } } return(1); }
public void MapAGSGroupEntityToEFApplicationRole(AGSGroupEntity groupEntity, EFApplicationRole efApplicationRole) { efApplicationRole.Id = groupEntity.Id; efApplicationRole.Name = groupEntity.Name; efApplicationRole.NormalizedName = groupEntity.Name; efApplicationRole.ConcurrencyStamp = CommonConstant.GenerateId(); }
public string CreateGroup(AGSGroupEntity model) { if (model == null) { throw new ArgumentNullException(); } if (!string.IsNullOrEmpty(model.Id)) { throw new ArgumentException(); } var result = _repository.GroupsRepository.Create(model); _repository.Save(); return(result); }
public AGSGroupEntity GetAGSGroupEntityFromEFApplicationRole(EFApplicationRole role) { var result = new AGSGroupEntity() { Id = role.Id, Name = role.Name, FunctionClaimIds = new List <string>() }; var functionClaimIds = this.GetFunctionClaimIdsByGroupId(role.Id); if (functionClaimIds != null) { result.FunctionClaimIds = functionClaimIds; } return(result); }
public string Create(AGSGroupEntity group) { // create a new role in ASP.NET identity core var role = new EFApplicationRole(); MapAGSGroupEntityToEFApplicationRole(group, role); role.Id = CommonConstant.GenerateId(); // assign id here _ = _roleManager.CreateAsync(role).Result; // update the associated Function Claims if (group.FunctionClaimIds != null) { foreach (var functionClaimId in group.FunctionClaimIds) { this.AddFunctionClaimToGroup(role, functionClaimId); } } return(role.Id); }
public int UpdateGroup(AGSGroupEntity model) { if (model == null) { throw new ArgumentNullException(); } if (string.IsNullOrEmpty(model.Id)) { throw new ArgumentException(); } var result = _repository.GroupsRepository.Update(model); if (result == 0) { throw new AGSException(AGSResponse.ResponseCodeEnum.ModelNotFound); } _repository.Save(); return(result); }
public IActionResult Post([FromBody] AGSGroupEntity group) { var result = _groupsHelper.CreateGroup(group); return(AGSResponseFactory.GetAGSResponseJsonResult(result)); }