public IActionResult Delete(Guid eventId, Guid serviceId, string id) { if (string.IsNullOrEmpty(id)) { return(BadRequest($"The card or veteran ID is null or empty.")); } var veteran = default(Veteran); if (int.TryParse(id, out var cardNumber)) { veteran = VeteranRepository .GetAll(new VeteranFilters() { CardNumber = cardNumber }) .SingleOrDefault(); } else if (Guid.TryParse(id, out var veteranId)) { veteran = VeteranRepository.Get(veteranId); } else { return(BadRequest($"The provided ID is neither a Card Number nor Veteran ID.")); } if (veteran == default(Veteran)) { return(StatusCode(404, $"The specified Card Number or Veteran Id doesn't match an enrolled Veteran.")); } var scan = ScanRepository.Get(eventId, veteran.Id, serviceId); if (scan == default(Scan)) { return(StatusCode(404, $"A Scan matching the specified information could not be found.")); } try { ScanRepository.Delete(eventId, veteran.Id, serviceId); return(NoContent()); } catch (Exception ex) { throw new Exception($"Error deleting the Scan matching the specified information: {ex.Message}. See inner Exception for details.", ex); } }
public IActionResult GetCheckIn(Guid eventId, string id) { if (string.IsNullOrEmpty(id)) { return(BadRequest($"The card or veteran ID is null or empty.")); } var veteran = default(Veteran); if (int.TryParse(id, out var cardNumber)) { veteran = VeteranRepository .GetAll(new VeteranFilters() { CardNumber = cardNumber }) .SingleOrDefault(); } else if (Guid.TryParse(id, out var veteranId)) { veteran = VeteranRepository.Get(veteranId); } else { return(BadRequest($"The provided ID is neither a Card Number nor Veteran ID.")); } if (veteran == default(Veteran)) { return(StatusCode(404, $"The specified Card Number or Veteran Id doesn't match an enrolled Veteran.")); } var scan = ScanRepository.Get(eventId, veteran.Id, Guid.Empty); if (scan == default(Scan)) { return(StatusCode(404, $"The Veteran has not checked in for this Event.")); } return(Ok(scan)); }
public IHttpActionResult Get(int id) { var result = _rep.Get(id); return(Ok(result)); }