public async Task <ActionResult> Move([FromBody] ListEntriesMoveRequest moveRequest) { var authorizationResult = await _authorizationService.AuthorizeAsync(User, moveRequest, new CatalogAuthorizationRequirement(ModuleConstants.Security.Permissions.Update)); if (!authorizationResult.Succeeded) { return(Unauthorized()); } var dstCatalog = (await _catalogService.GetByIdsAsync(new[] { moveRequest.Catalog })).FirstOrDefault(); if (dstCatalog.IsVirtual) { return(BadRequest("Unable to move to a virtual catalog")); } var categories = await _categoryMover.PrepareMoveAsync(moveRequest); var products = await _productMover.PrepareMoveAsync(moveRequest); await _categoryMover.ConfirmMoveAsync(categories); await _productMover.ConfirmMoveAsync(products); return(NoContent()); }
public async Task <BulkActionResult> ExecuteAsync(IEnumerable <IEntity> entities) { var entries = entities.Cast <ListEntryBase>().ToArray(); var moveInfo = new ListEntriesMoveRequest { Catalog = _context.CatalogId, Category = _context.CategoryId, ListEntries = entries }; ValidateMoveInfo(moveInfo); var categories = await _categoryListEntryMover.PrepareMoveAsync(moveInfo); var products = await _productListEntryMover.PrepareMoveAsync(moveInfo); await _categoryListEntryMover.ConfirmMoveAsync(categories); await _productListEntryMover.ConfirmMoveAsync(products); return(BulkActionResult.Success); }