public ActionResult DeleteConfirmed(int id) { TopicEV topicEV = db.TopicEVs.Find(id); db.TopicEVs.Remove(topicEV); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult RefuseTheDocument2(int?id) { if (id == null) { return(HttpNotFound()); } TopicEV topicEV = db.TopicEVs.Find(id); topicEV.Approved = false; db.Entry(topicEV).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("RefuseTheDocument")); }
// GET: TopicEVs/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TopicEV topicEV = db.TopicEVs.Find(id); if (topicEV == null) { return(HttpNotFound()); } return(View(topicEV)); }
public ActionResult Edit([Bind(Include = "Id,EvaluationFormId,SectionsId,TopicsId,TeacherId,Points,Approved,Nameproved")] TopicEV topicEV) { if (ModelState.IsValid) { db.Entry(topicEV).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Id = new SelectList(db.Documents, "Id", "Name", topicEV.Id); ViewBag.EvaluationFormId = new SelectList(db.EvaluationForm, "id", "id", topicEV.EvaluationFormId); ViewBag.SectionsId = new SelectList(db.Sections, "Id", "SectionName", topicEV.SectionsId); ViewBag.TeacherId = new SelectList(db.Teachers, "Id", "FullName", topicEV.TeacherId); ViewBag.TopicsId = new SelectList(db.Topics, "Id", "TopicName", topicEV.TopicsId); return(View(topicEV)); }
// GET: TopicEVs/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TopicEV topicEV = db.TopicEVs.Find(id); if (topicEV == null) { return(HttpNotFound()); } ViewBag.Id = new SelectList(db.Documents, "Id", "Name", topicEV.Id); ViewBag.EvaluationFormId = new SelectList(db.EvaluationForm, "id", "id", topicEV.EvaluationFormId); ViewBag.SectionsId = new SelectList(db.Sections, "Id", "SectionName", topicEV.SectionsId); ViewBag.TeacherId = new SelectList(db.Teachers, "Id", "FullName", topicEV.TeacherId); ViewBag.TopicsId = new SelectList(db.Topics, "Id", "TopicName", topicEV.TopicsId); return(View(topicEV)); }
public void SendNotification(TopicEV topicEV, int id) { var top = db.TopicEVs.Where(a => a.EvaluationFormId == topicEV.EvaluationFormId && a.TeacherId == topicEV.TeacherId && a.Approved == false); if (top.Count() <= 0) { WebMail.SmtpServer = "smtp.gmail.com"; WebMail.SmtpPort = 587; WebMail.SmtpUseDefaultCredentials = true; WebMail.EnableSsl = true; WebMail.UserName = "******"; WebMail.Password = "******"; string s = "رجع الموقع لمعرفة درجة تقيمك تم تقييمك من قبل اللجان"; var CurrentTeacher2 = db.UserToTeachers.Where(a => a.TeacherID == topicEV.TeacherId).SingleOrDefault(); WebMail.Send(to: CurrentTeacher2.User.Email, subject: "تقييم الاساتذه", body: s, isBodyHtml: true); db.Notifications.Add(new Notification { RecipientID = topicEV.TeacherId, AccountontID = id, Messagee = "تم تقيمك يمكن معرفة درجة تقيمك وتفاصيل التقيم", AddedOn = DateTime.Now }); db.SaveChanges(); } }
public ActionResult Edit([Bind(Include = "Id,EvaluationFormId,SectionsId,TopicsId,TeacherId,Points,Approved,Nameproved")] TopicEV topicEV, string submitButton) { if (ModelState.IsValid) { var topic = db.Topics.Find(topicEV.TopicsId); if (submitButton == "موافقه") { topicEV.Approved = true; var UserID = User.Identity.GetUserId(); var CurrentUser = db.Users.Where(a => a.Id == UserID).SingleOrDefault(); var CurrentTeacher = db.UserToTeachers.Where(a => a.UserID == UserID).SingleOrDefault(); var teacher = db.Teachers.Find(CurrentTeacher.TeacherID); var topics = db.Topics.Find(topicEV.TopicsId); var document = db.Documents.Where(a => a.TopicEVId == topicEV.Id); topicEV.Nameproved = teacher.FullName; var Currentcommit = db.CommHeeMembers.Where(a => a.Teacherid == CurrentTeacher.TeacherID).SingleOrDefault(); var Currentcommit3 = db.CommitHees.Where(a => a.id == Currentcommit.CommitHeesid).SingleOrDefault(); if (document != null) { topicEV.Points = (document.Count() * topics.DocPoints); } if (topicEV.Points > topics.TotalPoints) { topicEV.Points = topics.TotalPoints; } WebMail.SmtpServer = "smtp.gmail.com"; WebMail.SmtpPort = 587; WebMail.SmtpUseDefaultCredentials = true; WebMail.EnableSsl = true; WebMail.UserName = "******"; WebMail.Password = "******"; string s = " تم التقييم والموافقة على فقرة " + topics.TopicName + " \n من قبل " + Currentcommit3.comitname + ""; db.Notifications.Add(new Notification { RecipientID = topicEV.TeacherId, AccountontID = teacher.Id, Messagee = s, AddedOn = DateTime.Now }); db.Entry(topicEV).State = EntityState.Modified; db.SaveChanges(); SendNotification(topicEV, teacher.Id); var CurrentTeacher2 = db.UserToTeachers.Where(a => a.TeacherID == topicEV.TeacherId).SingleOrDefault(); WebMail.Send(to: CurrentTeacher2.User.Email, subject: "تقييم الاساتذه", body: s, isBodyHtml: true); //top = null; return(RedirectToAction("Assent")); } else { var UserID = User.Identity.GetUserId(); var CurrentUser = db.Users.Where(a => a.Id == UserID).SingleOrDefault(); var CurrentTeacher = db.UserToTeachers.Where(a => a.UserID == UserID).SingleOrDefault(); var teacher = db.Teachers.Find(CurrentTeacher.TeacherID); var Currentcommit = db.CommHeeMembers.Where(a => a.Teacherid == CurrentTeacher.TeacherID).SingleOrDefault(); var Currentcommit3 = db.CommitHees.Where(a => a.id == Currentcommit.CommitHeesid).SingleOrDefault(); var topics = db.Topics.Find(topicEV.TopicsId); topicEV.Nameproved = teacher.FullName; topicEV.Approved = true; topicEV.Points = 0; string s2 = "تم رفض فقرة " + topics.TopicName + " من قبل " + Currentcommit3.comitname + " اذا يوجود اعتراض يرجى مراجعة المعلومات"; db.Notifications.Add(new Notification { RecipientID = topicEV.TeacherId, AccountontID = teacher.Id, Messagee = s2, AddedOn = DateTime.Now }); db.Entry(topicEV).State = EntityState.Modified; db.SaveChanges(); WebMail.SmtpServer = "smtp.gmail.com"; WebMail.SmtpPort = 587; WebMail.SmtpUseDefaultCredentials = true; WebMail.EnableSsl = true; WebMail.UserName = "******"; WebMail.Password = "******"; var CurrentTeacher2 = db.UserToTeachers.Where(a => a.TeacherID == topicEV.TeacherId).SingleOrDefault(); string s = "تم رفض فقرة " + topics.TopicName + " من قبل " + Currentcommit3.comitname + " وفي حالة رفض الفقره تعطى درجة صفر اذا هناك اعتراض يرجلى مراجعة الموقع"; SendNotification(topicEV, teacher.Id); WebMail.Send(to: CurrentTeacher2.User.Email, subject: "تقييم الاساتذة", body: s, isBodyHtml: true); return(RedirectToAction("Assent")); } } ViewBag.Id = new SelectList(db.Documents, "Id", "Name", topicEV.Id); ViewBag.EvaluationFormId = new SelectList(db.EvaluationForm, "id", "id", topicEV.EvaluationFormId); ViewBag.SectionsId = new SelectList(db.Sections, "Id", "SectionName", topicEV.SectionsId); ViewBag.TeacherId = new SelectList(db.Teachers, "Id", "FullName", topicEV.TeacherId); ViewBag.TopicsId = new SelectList(db.Topics, "Id", "TopicName", topicEV.TopicsId); return(View(topicEV)); }