public async Task <PrintingEditionModel> DeletePrintingEditionAsync(long printingEditionId) { var responseModel = new PrintingEditionModel(); var printingEdition = await _printingEditionRepository.GetByIdAsync(printingEditionId); if (printingEdition == null) { responseModel.Errors.Add(Constants.Errors.InvalidData); return(responseModel); } var deleteResult = await _printingEditionRepository.DeleteAsync(printingEdition); if (deleteResult.Equals(0)) { responseModel.Errors.Add(Constants.Errors.FailedDelete); } var deleteAuthorsInPrintingEdition = await _authorInPrintingEditionRepository.DeletePrintingEditionsById(printingEditionId); if (deleteAuthorsInPrintingEdition.Equals(0)) { responseModel.Errors.Add(Constants.Errors.FailedDelete); } return(responseModel); }
public async Task DeletePrintingEditionAsync(long id) { var printingEdition = await _printingEditionRepository.GetByIdAsync(id); if (printingEdition is null) { throw new ServerException(Constants.Errors.PRINTING_EDITION_NOT_FOUND); } await _printingEditionRepository.DeleteAsync(printingEdition); }
public async Task DeleteAsync(long id) { if (await _printingEditionRepository.GetAsync(id) is null) { throw new UserException(HttpStatusCode.BadRequest, new List <string> { ExceptionsInfo.InvalidId }); } await _printingEditionRepository.DeleteAsync(id); }
public async Task <BaseModel> DeleteAsync(long id) { var response = new BaseModel(); var product = await _printingEditionRepository.GetByIdAsync(id); if (product == null) { response.Errors.Add(ErrorConstants.ImpossibleToFindProduct); return(response); } var result = await _printingEditionRepository.DeleteAsync(product); if (!result) { response.Errors.Add(ErrorConstants.ImpossibleToDeleteProduct); } response = await DeleteAuthorInProductAsync(product); return(response); }