public async Task UpdateBoxStatus(BoxStats boxstats) { var student = _studentRepository.GetStudentByRFID(boxstats.Rfid); var log = new BoxLog { dateTime = DateTime.Now }; var Box = _boxRepository.GetBox(); Box.IsOpen = boxstats.door; Box.StudentOppend = student; Box.StudentId = student.Id; if (boxstats.door) { if (student != null) { log.Message = "Box Door Opend By " + student.FullName; } else { log.Message = "Warning! Box Door opend by unknown User"; //activate warning } } if (!boxstats.door) { log.Message = "Box Door Closed"; } _boxRepository.AddLog(log); await _boxHub.Clients.All.SendAsync("doorStats", Box.StudentOppend.email, Box.IsOpen, DateTime.Now.ToString("HH:mm:ss")); await _notificationsRepository.AddNotificationAsync(log.Message); }