public async Task AnnouncePickup(ArrivalNotice details) { var errorMessage = String.Empty; if (Int32.TryParse(details.Car, out var registrationId)) { var students = await _studentDetailsHelper.GetStudentsForCar(registrationId); if (students.Any()) { var announcement = new PickupNotice() { Car = details.Car, Cone = details.Cone, Students = students.ToList(), PickupTimeUTC = DateTimeOffset.UtcNow }; await _dbHelper.AddPickupLog(announcement); await Clients.All.SendAsync("PickupAnnouncement", JsonConvert.SerializeObject(announcement)); await Clients.Caller.SendAsync("SuccessAnnouncement"); } else { errorMessage = $"Failed to locate students attached to Registration Id: {registrationId}."; } } else { errorMessage = $"Failed to convert {details.Car} to number."; } if (!string.IsNullOrWhiteSpace(errorMessage)) { await Clients.Caller.SendAsync("FailureAnnouncement", errorMessage); _logger.LogError(errorMessage); } }
public async Task <bool> Get(int id) { return((await _studentHelper.GetStudentsForCar(id)).Any()); }