Advertisement
Guest User

Untitled

a guest
Apr 4th, 2020
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 KB | None | 0 0
  1. public Response<Unit> UpdateIntegrationSettings(UpdateIntegrationSettingsCommand command){
    //_integrationSettingsCommandHandler.Update(command);

 using var scope = _dbScopeContext.CreateWriteDbScope();
  using var transaction = scope.BeginTransaction();
    
 var entity = scope
       .Query<ExternalIntegrationSettings>()
        .Include(it => it.Categories)
        .Include(it => it.OrganizationUnits)
     .FirstOrDefault(it => it.Id == command.EntityId);

 var model = ExternalIntegrationSettingsUpdateModel.Create(entity);
   command.UpdateModel(model);
  
 DeleteCategories(scope, entity.Categories, model.CategoryIdsToDelete);
   AddCategories(entity.Id, entity.Categories, model.CategoryIdsToAdd);
 
 DeleteOrganizationUnits(scope, entity.OrganizationUnits, model.OrganizationUnitIdsToDelete);
 AddOrganizationUnits(entity.Id, entity.OrganizationUnits, model.OrganizationUnitIdsToAdd);
   
 transaction.Success();

    return Response.Success();
}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement