示例#1
0
        public async Task <ReportToTeacherByScheduleIdResponse> ReportToTeacherByScheduleId(ReportToTeacherByScheduleIdRequest request)
        {
            int scheduleId       = Convert.ToInt32(request.ScheduleId);
            var reportedSchedule = _context.Schedules
                                   .Where(s => s.ScheduleId == scheduleId)
                                   .FirstOrDefault();

            if (reportedSchedule != null)
            {
                // Change attendance report status to Reported
                reportedSchedule.ReportStatus = "Reported";
                _context.SaveChanges();

                FirebaseNotificationModel firebaseNotiModel = new FirebaseNotificationModel()
                {
                    To           = "/topics/teacher_" + reportedSchedule.TeacherId,
                    Notification = new NotificationModel()
                    {
                        Title = "Attendance Report Date " + reportedSchedule.Date,
                        Body  = "Student with ID " + reportedSchedule.StudentId + " has reported attendance on slot " + reportedSchedule.SlotId
                    }
                };

                // Send notification to the responsible teacher and return response
                return(await FirebaseNotificationPusher.Send(firebaseNotiModel));
            }

            return(null);
        }
示例#2
0
        public HttpResponseMessage ReportToTeacher(ReportToTeacherByScheduleIdRequest request)
        {
            var response = _businessLogic.ReportToTeacherByScheduleId(request);

            return(Request.CreateResponse(HttpStatusCode.OK));
        }