public async Task <IActionResult> Delete([FromRoute] DeleteOperationsRequest request) { if (!ModelState.IsValid) { return(BadRequest(ModelState.GetErrorMessages())); } var response = await _operationService.DeleteListAsync(request); if (!response.IsValid) { return(BadRequest(response.Message)); } return(Ok(response)); }
public async Task <BaseResponse> DeleteListAsync(DeleteOperationsRequest request) { foreach (var operationId in request.OperationsIds) { var operation = await _operationRepository.GetAsync(operation => operation.Id == operationId); if (operation == null) { return(new ResultResponse <OperationDto>("Operation is not found")); } _operationRepository.Delete(operation); } await _unitOfWork.SaveChangesAsync(); return(new BaseResponse()); }