public async Task <EntityDeletedSuccessfully> DeleteById(string guid) { _logger.LogInfo($"Deleting assignment with id: {guid} ..."); var assignment = await _assignmentRepository.FindAssignmentById(Utils.checkGuidFormat(guid)); if (assignment != null) { _assignmentRepository.Delete(assignment); if (await _assignmentRepository.SaveAll()) { return(new EntityDeletedSuccessfully(DomainConsts.ENTITY_ASSIGNMENT, $"{DomainConsts.ENTITY_ASSIGNMENT} with id: {guid} is deleted successfully.", HttpStatusCode.OK)); } else { _logger.LogError($"Something went wrong while trying to delete assignment with id: {guid}"); throw new UnknownException($"Something went wrong while trying to delete assignment with id: {guid}", DomainConsts.APPLICATION_NAME); } } throw new EntityNotFoundException($"{DomainConsts.ENTITY_ASSIGNMENT} with id: {guid} not found.", DomainConsts.APPLICATION_NAME); }