public async Task <OperationResult <string> > DeleteBulkCategoryProperty(List <CategoryProperty> category, CancellationToken cancellation) { try { await context.BulkDeleteAsync(category); return(OperationResult <string> .BuildSuccessResult("Delete Success Full")); } catch (Exception ex) { return(OperationResult <string> .BuildFailure(ex.Message)); } }
public async Task <OperationResult <string> > SetAccess(AccessLevelDto accessLevels) { try { var currentRoleAccessValue = GetAccessLevels(accessLevels.RoleId); var currentAccess = currentRoleAccessValue.Select(x => x.Access).ToList(); var newAccess = accessLevels.Access.Except(currentAccess).ToList(); if (newAccess != null) { List <AccessLevel> accessLevelsL = new List <AccessLevel>(); foreach (var item in newAccess) { accessLevelsL.Add(new AccessLevel { Id = Guid.NewGuid(), Access = item, RoleId = accessLevels.RoleId }); } await context.BulkInsertAsync(accessLevelsL); } var removeItems = currentAccess.Except(accessLevels.Access).ToList(); if (removeItems != null) { List <AccessLevel> accessLevelsL = new List <AccessLevel>(); foreach (var item in removeItems) { var accClaim = currentRoleAccessValue.SingleOrDefault(x => x.Access == item); if (accClaim != null) { accessLevelsL.Add(accClaim); } } await context.BulkDeleteAsync(accessLevelsL); } return(OperationResult <string> .BuildSuccessResult("SuccessAdd")); } catch (Exception ex) { return(OperationResult <string> .BuildFailure(ex)); } }