コード例 #1
0
        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);
            }
        }
コード例 #2
0
 public async Task <bool> Get(int id)
 {
     return((await _studentHelper.GetStudentsForCar(id)).Any());
 }