Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        public async Task GetUpdate()
        {
            Box       box       = _boxRepository.GetBox();
            Item      item1     = _itemRepository.GetItemById(1);
            Item      item2     = _itemRepository.GetItemById(2);
            Students  students1 = _studentRepository.GetStudentById(box.StudentId);
            Students  students2 = _studentRepository.GetStudentById(item1.StudentId);
            Students  students3 = _studentRepository.GetStudentById(item2.StudentId);
            ItemCount itemCount = await _itemRepository.GetCount();

            await Clients.Caller.SendAsync("doorStats", students1.FullName, box.IsOpen, DateTime.Now.ToString("HH:mm:ss"));

            await Clients.Caller.SendAsync("Item1", students2.FullName, item1.IsInBox, DateTime.Now.ToString("HH:mm:ss"));

            await Clients.Caller.SendAsync("Item2", students3.FullName, item2.IsInBox, DateTime.Now.ToString("HH:mm:ss"));

            await Clients.Caller.SendAsync("TimesBorrowedToday", itemCount.TimesBorrowed, itemCount.Time, DateTime.Now.ToString("HH:mm:ss"));
        }