public IActionResult Batch(Guid batchId) { if (batchId == Guid.Empty) { _logger.Log(LogLevel.Error, $"Bad Request - could be an invalid batch ID format. Batch IDs should be a GUID. A valid GUID that doesn't match a batch ID will return a 404"); return(BadRequest("Bad Request - could be an invalid batch ID format. Batch IDs should be a GUID. A valid GUID that doesn't match a batch ID will return a 404")); } _logger.Log(LogLevel.Information, "Getting batch with id={ID}", batchId); try { Batch batch = _batchData.GetBatch(batchId); if (batch == null) { _logger.Log(LogLevel.Warning, $"Batch with given id = {batchId} does not exists"); return(NotFound("Not- Found - Could that be the batch ID does not exists")); } else { if (batch.ExpiryDate < DateTime.Now) //expiry date check { _logger.Log(LogLevel.Warning, "Gone - the batch has been expired and is no longer available"); return(StatusCode(410, "Gone - the batch has been expired and is no longer available")); } } _logger.Log(LogLevel.Information, "Batch details retrieved"); return(Ok(batch)); } catch (Exception ex) { _logger.Log(LogLevel.Error, ex.Message); return(BadRequest()); } }