Пример #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            AspNetPTMAttendance aspNetPTMAttendance = db.AspNetPTMAttendances.Find(id);

            db.AspNetPTMAttendances.Remove(aspNetPTMAttendance);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #2
0
 public ActionResult Edit([Bind(Include = "Id,MeetingID,ParentID,SubjectID,Status,Rating")] AspNetPTMAttendance aspNetPTMAttendance)
 {
     if (ModelState.IsValid)
     {
         db.Entry(aspNetPTMAttendance).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("ParentTeacherMeeting", "Teacher_Dashboard"));
     }
     ViewBag.MeetingID = new SelectList(db.AspNetParentTeacherMeetings.Where(x => x.SessionID == SessionID), "Id", "Title", aspNetPTMAttendance.MeetingID);
     ViewBag.ParentID  = new SelectList(db.AspNetUsers.Where(x => x.AspNetRoles.Select(y => y.Name).Contains("Parent") && x.Status != "False" && x.AspNetUsers_Session.Any(y => y.SessionID == SessionID)), "Id", "Email", aspNetPTMAttendance.ParentID);
     ViewBag.SubjectID = new SelectList(db.AspNetSubjects.Where(x => x.AspNetClass.SessionID == SessionID), "Id", "SubjectName", aspNetPTMAttendance.SubjectID);
     return(View(aspNetPTMAttendance));
 }
Пример #3
0
        // GET: AspNetPTMAttendance/Edit/5
        public PartialViewResult Edit(string studentId, int subjectID)
        {
            string ChildID   = studentId;
            string parentID  = db.AspNetParent_Child.Where(x => x.ChildID == ChildID).Select(x => x.ParentID).FirstOrDefault();
            int    meetingID = db.AspNetParentTeacherMeetings.Max(x => x.Id);

            AspNetPTMAttendance aspNetPTMAttendance = db.AspNetPTMAttendances.Where(x => x.MeetingID == meetingID && x.SubjectID == subjectID && x.ParentID == parentID).FirstOrDefault();

            Session["PTMID"]  = aspNetPTMAttendance.Id;
            ViewBag.MeetingID = new SelectList(db.AspNetParentTeacherMeetings.Where(x => x.SessionID == SessionID), "Id", "Title", aspNetPTMAttendance.MeetingID);
            ViewBag.ParentID  = new SelectList(db.AspNetUsers.Where(x => x.AspNetRoles.Select(y => y.Name).Contains("Parent") && x.Status != "False" && x.AspNetUsers_Session.Any(y => y.SessionID == SessionID)), "Id", "Email", aspNetPTMAttendance.ParentID);
            ViewBag.SubjectID = new SelectList(db.AspNetSubjects.Where(x => x.AspNetClass.SessionID == SessionID), "Id", "SubjectName", aspNetPTMAttendance.SubjectID);
            return(PartialView(aspNetPTMAttendance));
        }
Пример #4
0
        // GET: AspNetPTMAttendance/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AspNetPTMAttendance aspNetPTMAttendance = db.AspNetPTMAttendances.Find(id);

            if (aspNetPTMAttendance == null)
            {
                return(HttpNotFound());
            }
            return(View(aspNetPTMAttendance));
        }
        public ActionResult Create([Bind(Include = "Id,Title,Description,Date,Time,Status")] AspNetParentTeacherMeeting aspNetParentTeacherMeeting, AspNetAnnouncement aspNetAnnouncement)
        {
            if (ModelState.IsValid)
            {
                var transactionObj = db.Database.BeginTransaction();
                try
                {
                    var Session = db.AspNetSessions.Where(x => x.Status == "Active").FirstOrDefault().Id;
                    aspNetParentTeacherMeeting.SessionID = Session;

                    db.AspNetParentTeacherMeetings.Add(aspNetParentTeacherMeeting);
                    db.SaveChanges();
                    int        MeetingID     = db.AspNetParentTeacherMeetings.Max(x => x.Id);
                    List <int> SubjectIDs    = db.AspNetSubjects.Where(x => x.AspNetClass.SessionID == Session).Select(x => x.Id).ToList();
                    var        parentSubject = (from parentchild in db.AspNetParent_Child
                                                join studentsubject in db.AspNetStudent_Subject on parentchild.ChildID equals studentsubject.StudentID
                                                where SubjectIDs.Contains(studentsubject.SubjectID)
                                                select new { parentchild.ParentID, studentsubject.SubjectID }).ToList();
                    foreach (var parentsubject in parentSubject)
                    {
                        AspNetPTMAttendance PTMAttendace = new AspNetPTMAttendance();
                        PTMAttendace.ParentID  = parentsubject.ParentID;
                        PTMAttendace.SubjectID = parentsubject.SubjectID;
                        PTMAttendace.Status    = "Absent";
                        PTMAttendace.Rating    = -1;
                        PTMAttendace.MeetingID = MeetingID;
                        db.AspNetPTMAttendances.Add(PTMAttendace);
                        db.SaveChanges();

                        int        PTMAttendaceID    = db.AspNetPTMAttendances.Max(x => x.Id);
                        List <int> ParentQuestionIDs = db.AspNetFeedBackForms.Where(x => x.AspNetPTMFormRole.RoleName == "Parent" && x.SessionID == Session).Select(x => x.Id).ToList();
                        foreach (var questionID in ParentQuestionIDs)
                        {
                            AspNetPTM_ParentFeedback PTM_ParentFeedback = new AspNetPTM_ParentFeedback();
                            PTM_ParentFeedback.PTMID     = PTMAttendaceID;
                            PTM_ParentFeedback.HeadingID = questionID;
                            db.AspNetPTM_ParentFeedback.Add(PTM_ParentFeedback);
                            db.SaveChanges();
                        }
                        List <int> TeacherQuestionIDs = db.AspNetFeedBackForms.Where(x => x.AspNetPTMFormRole.RoleName == "Teacher" && x.SessionID == Session).Select(x => x.Id).ToList();
                        foreach (var questionID in TeacherQuestionIDs)
                        {
                            AspNetPTM_TeacherFeedback PTM_TeacherFeedback = new AspNetPTM_TeacherFeedback();
                            PTM_TeacherFeedback.PTMID     = PTMAttendaceID;
                            PTM_TeacherFeedback.HeadingID = questionID;
                            db.AspNetPTM_TeacherFeedback.Add(PTM_TeacherFeedback);
                            db.SaveChanges();
                            ///////////////////////////////////////////////////////////////////////////////////////////
                        }
                    }


                    var NotificationObj = new AspNetNotification();
                    NotificationObj.Description = aspNetParentTeacherMeeting.Description;
                    NotificationObj.Subject     = aspNetParentTeacherMeeting.Title;
                    NotificationObj.SenderID    = User.Identity.GetUserId();
                    NotificationObj.Time        = DateTime.Now;
                    NotificationObj.SessionID   = Session;
                    db.AspNetNotifications.Add(NotificationObj);
                    db.SaveChanges();

                    var NotificationID = db.AspNetNotifications.Max(x => x.Id);
                    var receiverId     = (from teacher in db.AspNetUsers.Where(x => x.Status != "False" && x.AspNetUsers_Session.Any(y => y.SessionID == Session))
                                          where teacher.AspNetRoles.Select(y => y.Name).Contains("Teacher") ||
                                          teacher.AspNetRoles.Select(y => y.Name).Contains("Student") ||
                                          teacher.AspNetRoles.Select(y => y.Name).Contains("Parent")

                                          select new { teacher.Id }).ToList();

                    List <string> obled = new List <string>();

                    foreach (var sender in receiverId)
                    {
                        var notificationRecieve = new AspNetNotification_User();
                        notificationRecieve.NotificationID = NotificationID;
                        notificationRecieve.UserID         = sender.Id;
                        notificationRecieve.Seen           = false;
                        db.AspNetNotification_User.Add(notificationRecieve);
                        db.SaveChanges();



                        obled.Add(sender.Id);
                    }

                    //Message start
                    //var classe = db.AspNetClasses.Where(p => p.Id == aspNetHomework.ClassId).FirstOrDefault();
                    Utility obj = new Utility();
                    obj.SMSToOffitialsp("Dear Principal, Parent Teacher Meeting is scheduled on" + aspNetParentTeacherMeeting.Date + " at " + aspNetParentTeacherMeeting.Time + "., Title : " + aspNetParentTeacherMeeting.Title + " IPC NGS Preschool, Aziz Avenue, Lahore.");
                    obj.SMSToOffitialsa("Dear Admin, Parent Teacher Meeting is scheduled on " + aspNetParentTeacherMeeting.Date + " at " + aspNetParentTeacherMeeting.Time + "., Title : " + aspNetParentTeacherMeeting.Title + " IPC NGS Preschool, Aziz Avenue, Lahore.");
                    AspNetMessage oob = new AspNetMessage();
                    oob.Message = "Dear Parent, The Parent Teacher Meeting is scheduled on " + aspNetParentTeacherMeeting.Date + " at " + aspNetParentTeacherMeeting.Time + ". Your regularity and punctuality will be appreciated. IPC NGS Preschool, Aziz Avenue, Lahore.";
                    //oob.Message = "Parent Teacher Meeting is arranged,  Title : " + aspNetParentTeacherMeeting.Title + "For discription login to Portal please";
                    obj.SendSMS(oob, obled);
                    //Message end



                    var PTMNOTIFICATIOn = new AspNetNotificationController();
                    PTMNOTIFICATIOn.PTMNotification();
                    db.SaveChanges();
                    transactionObj.Commit();
                }

                catch (Exception ex)
                {
                    transactionObj.Dispose();
                }
                return(RedirectToAction("Index"));
            }

            return(View(aspNetParentTeacherMeeting));
        }