public async Task AddPickupLog(PickupNotice pickupNotice) { var pickupLogs = new List <PickupDAO>(); foreach (var student in pickupNotice.Students) { pickupLogs.Add(new PickupDAO() { Cone = Int32.Parse(pickupNotice.Cone), GradeLevel = student.GradeLevel, Name = student.Name, PickupTimeUTC = pickupNotice.PickupTimeUTC, RegistrationId = Int32.Parse(pickupNotice.Car), Teacher = student.Teacher }); } await _dbService.Insert <PickupDAO>(pickupLogs); }
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 AddPickupLog(PickupNotice pickupNotice) { var jsonData = JsonConvert.SerializeObject(pickupNotice); await _dbService.ExecuteStoredProcedure(Sprocs.AddPickupLog, new Dictionary <string, object>() { { "json", jsonData } }); }