// // GET: /StudentStoreItemRepository/Create public ActionResult Create(int?id, string level) { PrimarySchoolStudent theStudent = work.PrimarySchoolStudentRepository.GetByID(id); List <Store> theStoreItems = work.StoreRepository.Get(a => a.Level.Equals(level)).ToList(); List <Store> theStoreItemWithoutClass = work.StoreRepository.Get(a => a.Level == null).ToList(); List <Store> theItems = new List <Store>(); foreach (var item in theStoreItems) { theItems.Add(item); } foreach (var item in theStoreItemWithoutClass) { theItems.Add(item); } StudentItemViewModel theItemViewModel = new StudentItemViewModel(); theItemViewModel.StudentStoreItem = theItems; theItemViewModel.StudentID = theStudent.UserID; theItemViewModel.StudentName = theStudent.LastName; theItemViewModel.Level = theStudent.PresentLevel; // theItemViewModel. return(View(theItemViewModel)); }
public ActionResult Delete(PrimarySchoolStudent model) { try { // TODO: Add delete logic here SecondarySchoolStudent theStudent = work.SecondarySchoolStudentRepository.GetByID(model.PersonID); string firstName = model.FirstName; string lastName = model.LastName; work.SecondarySchoolStudentRepository.Delete(theStudent); Membership.DeleteUser(Convert.ToString(theStudent.UserID)); work.Save(); if (User.Identity.Name != "5000001") { AuditTrail audit = new AuditTrail { Date = DateTime.Now, Action = "Student was Deleted, First Name:-" + firstName + " Last Name:-" + lastName, UserID = User.Identity.Name }; work.AuditTrailRepository.Insert(audit); work.Save(); } return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Edit(string id, string level) { Int32 theId = Convert.ToInt32(Models.Encript.DecryptString(id, true)); PrimarySchoolStudent theStudent = work.PrimarySchoolStudentRepository.GetByID(theId); List <Store> theStoreItems = work.StoreRepository.Get(a => a.Level.Equals(level)).OrderBy(a => a.ItemName).ToList(); List <Store> theStoreItemWithoutClass = work.StoreRepository.Get(a => a.Level == "").OrderBy(a => a.ItemName).ToList(); List <Store> theItems = new List <Store>(); foreach (var item in theStoreItems) { theItems.Add(item); } foreach (var item in theStoreItemWithoutClass) { theItems.Add(item); } StudentItemViewModel theItemViewModel = new StudentItemViewModel(); theItemViewModel.StudentStoreItem = theItems; theItemViewModel.StudentID = theStudent.UserID; theItemViewModel.StudentName = theStudent.LastName; theItemViewModel.Level = theStudent.PresentLevel; // theItemViewModel. return(View(theItemViewModel)); }
public ActionResult Index(int?page, string sortOrder, string currentFilter) { int pageSize = 40; int pageNumber = (page ?? 1); Int32 theUserName = Convert.ToInt32(User.Identity.Name); Person theStudent = work.PersonRepository.Get(a => a.UserID == theUserName).First(); if (theStudent is PrimarySchoolStudent) { PrimarySchoolStudent theStudent1 = work.PrimarySchoolStudentRepository.Get(a => a.UserID == theUserName).First(); List <Post> thePost = work.PostRepository.Get(a => a.Class == theStudent1.LevelType).ToList(); //List<Post> thePost = work.PostRepository.Get(a => a.Level.Equals(theStudent1.PresentLevel) || a.Class == theStudent1.PresentLevel).ToList(); // return View(); // List<Post> thePost = work.PostRepository.Get(a =>a.Class.Equals(theStudent1.PresentLevel)).ToList(); return(View(thePost.OrderByDescending(a => a.DateCreated).ToPagedList(pageNumber, pageSize))); // return View(thePost.OrderByDescending(a => a.DateCreated)); } if (theStudent is PrimarySchoolStaff) { PrimarySchoolStaff staff = work.PrimarySchoolStaffRepository.Get(a => a.UserID == theUserName).First(); // List<Post> thePostStudent = new List<Post>(); // staff. List <Post> thePost = work.PostRepository.Get(a => a.Level.Equals("Non-Student")).ToList(); //if (staff.ClassTeacherOf != null) //{ // string[] theClass = staff.ClassTeacherOf.Split(':'); // if (theClass[0] != null) // { // string teacherClass = theClass[0]; // List<Post> thePostStudent = work.PostRepository.Get(a => a.Level.Equals(teacherClass)).ToList(); // thePost.AddRange(thePostStudent); // // ViewBag.Delete = "True"; // } //} // List<Post> thePostStudent = work.PostRepository.Get(a => a.Level).ToList(); // return View(); return(View(thePost.OrderByDescending(a => a.DateCreated).ToPagedList(pageNumber, pageSize))); // return View(thePost.OrderByDescending(a => a.DateCreated)); } return(View()); }
public ActionResult ViewFeeForStudent(int id, string term) { PrimarySchoolStudent theStudent = work.PrimarySchoolStudentRepository.GetByID(id); List <SchoolFeePayment> theStudentFeesPayment = work.SchoolFeePaymentRepository.Get(a => a.StudentID == theStudent.UserID && a.Level.Equals(theStudent.PresentLevel) && a.Term.Equals(term)).ToList(); // PopulateActivity(theStudent, theStudentFeesPayment, term); if (theStudentFeesPayment.Count == 0) { return(View("ViewSchoolFee", new SchoolFeePayment() { Level = theStudent.PresentLevel, StudentID = theStudent.UserID })); } else { return(View("ViewSchoolFee", theStudentFeesPayment[0])); } }
// // GET: /Information/ public ActionResult Index() { if (User.IsInRole("Student")) { Membership.GetUser(true); string theUser = Convert.ToString(User.Identity.Name); Int32 theUser1 = Convert.ToInt32(User.Identity.Name); PrimarySchoolStudent theStudent = work.PrimarySchoolStudentRepository.Get(a => a.UserID == theUser1).First(); List <Information> PersonalInfo = work.InformationRepository.Get(a => a.StudentID.Equals(theUser)).ToList(); List <Information> theInfo = work.InformationRepository.Get(a => a.To.Equals(theStudent.PresentLevel)).ToList(); PersonalInfo.AddRange(theInfo); return(View(PersonalInfo.OrderByDescending(a => a.DateSent))); } else { Membership.GetUser(true); string theUser = Convert.ToString(User.Identity.Name); List <Information> theInfo = work.InformationRepository.Get(a => a.SentBy.Equals(theUser)).ToList(); return(View(theInfo.OrderByDescending(a => a.DateSent))); } return(View()); }
public ActionResult Create(Post model) { if (User.IsInRole("Student")) { Int32 userId = Convert.ToInt32(User.Identity.Name); PrimarySchoolStudent theUser = work.PrimarySchoolStudentRepository.Get(a => a.UserID == userId).First(); model.Class = theUser.LevelType; } if (string.IsNullOrEmpty(model.Class)) { List <Level> theLevels = work.LevelRepository.Get().ToList(); List <SelectListItem> theItem = new List <SelectListItem>(); theItem.Add(new SelectListItem() { Text = "None", Value = "" }); foreach (var level in theLevels) { theItem.Add(new SelectListItem() { Text = level.LevelName + ":" + level.Type, Value = level.LevelName + ":" + level.Type }); } ViewData["arm"] = theItem; ModelState.AddModelError("", " Please Choose a Class Arm!"); return(View()); } Int32 theUserName = Convert.ToInt32(User.Identity.Name); Person thePerson = work.PersonRepository.Get(a => a.UserID == theUserName).First(); model.DateCreated = DateTime.Now; if (thePerson is PrimarySchoolStudent) { PrimarySchoolStudent theStudent = work.PrimarySchoolStudentRepository.Get(a => a.UserID == theUserName).First(); // PrimarySchoolStudent new model.Level = theStudent.PresentLevel; } else { model.Level = "Non-Student"; } model.PosterName = thePerson.UserID; model.RealName = thePerson.FirstName + " " + thePerson.LastName; try { if (ModelState.IsValid) { work.PostRepository.Insert(model); work.Save(); } // TODO: Add insert logic here return(RedirectToAction("Index")); } catch { List <Level> theLevels = work.LevelRepository.Get().ToList(); List <SelectListItem> theItem = new List <SelectListItem>(); theItem.Add(new SelectListItem() { Text = "None", Value = "" }); foreach (var level in theLevels) { theItem.Add(new SelectListItem() { Text = level.LevelName + ":" + level.Type, Value = level.LevelName + ":" + level.Type }); } ViewData["arm"] = theItem; return(View()); } }
// // GET: /PractiseSave/ public ActionResult Index(string studentID, string level = "", string term = "", int id = 0) { if (User.IsInRole("Parent")) { Int32 theUser = Convert.ToInt32(User.Identity.Name); List <PrimarySchoolStudent> thSchoolStudents; // string userid = User.Identity.Name; List <Parent> theP = work.ParentRepository.Get(a => a.UserID == theUser).ToList(); Parent theRealParent = theP[0]; int idParent = theRealParent.ParentID; thSchoolStudents = work.PrimarySchoolStudentRepository.Get(a => a.ParentID == idParent).ToList(); List <SelectListItem> theItem = new List <SelectListItem>(); foreach (var s in thSchoolStudents) { theItem.Add(new SelectListItem() { Text = s.LastName + " " + s.FirstName, Value = s.PersonID.ToString() }); ViewData["Students"] = theItem; } } if (User.IsInRole("Student")) { Membership.GetUser(true); string theUser = User.Identity.Name.ToString(); ViewBag.Level = "Student ID -" + theUser + " Class -" + level + "Term -" + term; List <PractiseSave> thePractiseExam = work.PractiseSaveRepository.Get(a => a.Level.Equals(level) && a.Term.Equals(term) && a.StudentID.Equals(theUser)).ToList(); return(View(thePractiseExam)); } if (User.IsInRole("Parent")) { // int userID = Convert.ToInt32(User.Identity.Name); Int32 theUser = Convert.ToInt32(User.Identity.Name); Parent theP = work.ParentRepository.Get(a => a.UserID == theUser).First(); if (studentID != null) { int ids = Convert.ToInt32(studentID); PrimarySchoolStudent theStudents = work.PrimarySchoolStudentRepository.GetByID(ids); if (theStudents != null) { string userID = Convert.ToString(theStudents.UserID); ViewBag.Level = "Student ID -" + userID + " Class -" + level + "Term -" + term; List <PractiseSave> thePractiseExam = work.PractiseSaveRepository.Get(a => a.Level.Equals(level) && a.Term.Equals(term) && a.StudentID.Equals(userID)).ToList(); return(View(thePractiseExam)); } else { string userID = Convert.ToString(theStudents.UserID); ViewBag.Level = "Student ID -" + userID + " Class -" + level + "Term -" + term; List <PractiseSave> thePractiseExam = work.PractiseSaveRepository.Get(a => a.Level.Equals(level) && a.Term.Equals(term) && a.StudentID == "0").ToList(); return(View(thePractiseExam)); } } else { //string userID = "0";// Convert.ToString(theStudents.UserID); // ViewBag.Level = "Student ID -" + theUser + " Class -" + level + "Term -" + term; ViewBag.Level = "Student ID -" + " " + " Class -" + level + "Term -" + term; List <PractiseSave> thePractiseExam = work.PractiseSaveRepository.Get(a => a.Level.Equals(level) && a.Term.Equals(term) && a.StudentID == "0").ToList(); return(View(thePractiseExam)); } } if (User.IsInRole("Teacher")) { Membership.GetUser(true); ViewBag.ID = id; PrimarySchoolStudent theStudent = work.PrimarySchoolStudentRepository.GetByID(id); string StudentID = Convert.ToString(id); List <PractiseSave> thePractiseExam = new List <PractiseSave>(); if (theStudent != null) { Int32 theTeacher = Convert.ToInt32(User.Identity.Name); PrimarySchoolStaff theStaff = work.PrimarySchoolStaffRepository.Get(a => a.UserID == theTeacher).First(); string theStudentID = theStudent.UserID.ToString(); thePractiseExam = work.PractiseSaveRepository.Get(a => a.LevelType.Equals(theStaff.ClassTeacherOf) && a.Term.Equals(term) && a.StudentID.Equals(theStudentID)).ToList(); } return(View(thePractiseExam)); } else { Membership.GetUser(true); ViewBag.ID = id; PrimarySchoolStudent theStudent = work.PrimarySchoolStudentRepository.GetByID(id); string StudentID = Convert.ToString(id); List <PractiseSave> thePractiseExam = new List <PractiseSave>(); if (theStudent != null) { Int32 theTeacher = Convert.ToInt32(User.Identity.Name); PrimarySchoolStaff theStaff = work.PrimarySchoolStaffRepository.Get(a => a.UserID == theTeacher).First(); string theStudentID = theStudent.UserID.ToString(); thePractiseExam = work.PractiseSaveRepository.Get(a => a.Level.Equals(theStudent.PresentLevel) && a.Term.Equals(term) && a.StudentID.Equals(theStudentID)).ToList(); } return(View(thePractiseExam)); } }
// public ActionResult Index(string arm, string date, string dateto, string studentid, string present) public ActionResult StudentView(string date, string present, string dateto, string studentID) { Int32 theUser = Convert.ToInt32(User.Identity.Name); List <PrimarySchoolStudent> thSchoolStudents; if (User.IsInRole("Parent")) { string userid = User.Identity.Name; List <Parent> theP = work.ParentRepository.Get(a => a.UserID == theUser).ToList(); Parent theRealParent = theP[0]; int idParent = theRealParent.ParentID; thSchoolStudents = work.PrimarySchoolStudentRepository.Get(a => a.ParentID == idParent).ToList(); List <SelectListItem> theItem = new List <SelectListItem>(); // theItem.Add(new SelectListItem() { Text = "None", Value = "" }); foreach (var s in thSchoolStudents) { theItem.Add(new SelectListItem() { Text = s.LastName + " " + s.FirstName, Value = s.PersonID.ToString() }); ViewData["Students"] = theItem; } } //List<Level> theLevels = work.LevelRepository.Get().ToList(); List <Attendance> theAtten = new List <Attendance>(); if (User.IsInRole("Student")) { // string theUserID = User.Identity.Name; // ViewData["arm"] = theItem; theAtten = work.AttendanceRepository.Get(a => a.StudentID == theUserID).OrderByDescending(a => a.DateTaken).ToList(); } else { //List<Parent> theP = work.ParentRepository.Get(a => a.UserID == theUser).ToList(); //Parent theRealParent = theP[0]; //int idParent = theRealParent.ParentID; //thSchoolStudents = work.PrimarySchoolStudentRepository.Get(a => a.ParentID == idParent).ToList(); //if (thSchoolStudents.Count() > 0) //{ // PrimarySchoolStudent p = thSchoolStudents[0]; // string id = p.UserID.ToString(); if (studentID != null) { theAtten = work.AttendanceRepository.Get().OrderByDescending(a => a.DateTaken).ToList(); } else { theAtten = new List <Attendance>(); } // theAtten = theAtten.Where(a => a.StudentID == id).ToList(); //} //else //{ // theAtten = new List<Attendance>(); //} } if (User.IsInRole("Student")) { if (!String.IsNullOrEmpty(date) && !(String.IsNullOrEmpty(dateto))) { DateTime from = Convert.ToDateTime(date); DateTime to = Convert.ToDateTime(dateto); theAtten = theAtten.Where(a => a.DateTaken >= from && a.DateTaken <= to).ToList(); } if (!String.IsNullOrEmpty(studentID)) { int id = Convert.ToInt32(studentID); PrimarySchoolStudent p = work.PrimarySchoolStudentRepository.GetByID(id); string stringId = p.UserID.ToString(); theAtten = theAtten.Where(a => a.StudentID == stringId).ToList(); } if (!(String.IsNullOrEmpty(present))) { bool presentValue = Convert.ToBoolean(present); theAtten = theAtten.Where(s => s.Present == presentValue).ToList(); // DateTime d = Convert.ToDateTime(date); // theAtten = null;// theAtten.Where(s => s.DateTaken.Date == d.Date).ToList(); } } else { if (!String.IsNullOrEmpty(date) && !(String.IsNullOrEmpty(dateto)) && !(String.IsNullOrEmpty(studentID))) { int id = Convert.ToInt32(studentID); PrimarySchoolStudent p = work.PrimarySchoolStudentRepository.GetByID(id); int ids = p.UserID; string stringId = ids.ToString(); DateTime from = Convert.ToDateTime(date); DateTime to = Convert.ToDateTime(dateto); theAtten = theAtten.Where(a => a.DateTaken >= from && a.DateTaken <= to && a.StudentID == stringId).ToList(); } if (!String.IsNullOrEmpty(studentID)) { int id = Convert.ToInt32(studentID); PrimarySchoolStudent p = work.PrimarySchoolStudentRepository.GetByID(id); string stringId = p.UserID.ToString(); theAtten = theAtten.Where(a => a.StudentID == stringId).ToList(); } if (!String.IsNullOrEmpty(present) && !(String.IsNullOrEmpty(studentID))) { bool presentValue = Convert.ToBoolean(present); theAtten = theAtten.Where(s => s.Present == presentValue).ToList(); } } ViewBag.Count = theAtten.Count(); return(View(theAtten)); }
public ActionResult Index(string arm, string studentID) { if (User.IsInRole("Parent")) { Int32 theUser = Convert.ToInt32(User.Identity.Name); List <PrimarySchoolStudent> thSchoolStudents; // string userid = User.Identity.Name; List <Parent> theP = work.ParentRepository.Get(a => a.UserID == theUser).ToList(); Parent theRealParent = theP[0]; int idParent = theRealParent.ParentID; thSchoolStudents = work.PrimarySchoolStudentRepository.Get(a => a.ParentID == idParent).ToList(); List <SelectListItem> theItem1 = new List <SelectListItem>(); foreach (var s in thSchoolStudents) { theItem1.Add(new SelectListItem() { Text = s.LastName + " " + s.FirstName, Value = s.PersonID.ToString() }); ViewData["Students"] = theItem1; } } List <Level> theLevels = work.LevelRepository.Get().ToList(); List <SelectListItem> theItem = new List <SelectListItem>(); theItem.Add(new SelectListItem() { Text = "None", Value = "" }); foreach (var level in theLevels) { theItem.Add(new SelectListItem() { Text = level.LevelName + ":" + level.Type, Value = level.LevelName + ":" + level.Type }); } ViewData["arm"] = theItem; List <List <TimeTable> > theTimeTable1 = TimeTableCollisionAviodance.DisplayTimeTable(arm); ViewBag.TimeTable = theTimeTable1; int userId = 0;// Convert.ToInt32(User.Identity.Name); if (User.IsInRole("Parent")) { Int32 theUser = Convert.ToInt32(User.Identity.Name); Parent theP = work.ParentRepository.Get(a => a.UserID == theUser).First(); if (studentID != null) { int id = Convert.ToInt32(studentID); // userId = Convert.ToInt32(User.Identity.Name); List <PrimarySchoolStudent> theStaff = work.PrimarySchoolStudentRepository.Get(a => a.PersonID == id).ToList(); if (theStaff.Count() > 0) { PrimarySchoolStudent theRealStudent = theStaff[0]; string theArm = theRealStudent.LevelType; List <List <TimeTable> > theTimeTable = TimeTableCollisionAviodance.DisplayTimeTable(theArm); ViewBag.TimeTable = theTimeTable; return(View()); } } } if (string.IsNullOrEmpty(arm) && User.IsInRole("Student")) { userId = Convert.ToInt32(User.Identity.Name); List <PrimarySchoolStudent> theStaff = work.PrimarySchoolStudentRepository.Get(a => a.UserID == userId).ToList(); if (theStaff.Count() > 0) { PrimarySchoolStudent theRealStudent = theStaff[0]; string theArm = theRealStudent.LevelType; List <List <TimeTable> > theTimeTable = TimeTableCollisionAviodance.DisplayTimeTable(theArm); ViewBag.TimeTable = theTimeTable; return(View()); } } return(View()); }
public ActionResult StudentTimeTableView(string studentID) { if (User.IsInRole("Parent")) { Int32 theUser = Convert.ToInt32(User.Identity.Name); List <PrimarySchoolStudent> thSchoolStudents; // string userid = User.Identity.Name; List <Parent> theP = work.ParentRepository.Get(a => a.UserID == theUser).ToList(); Parent theRealParent = theP[0]; int idParent = theRealParent.ParentID; thSchoolStudents = work.PrimarySchoolStudentRepository.Get(a => a.ParentID == idParent).ToList(); List <SelectListItem> theItem = new List <SelectListItem>(); foreach (var s in thSchoolStudents) { theItem.Add(new SelectListItem() { Text = s.LastName + " " + s.FirstName, Value = s.PersonID.ToString() }); ViewData["Students"] = theItem; } } int userId = 0;//Convert.ToInt32(User.Identity.Name); // int userID = 0; //=// Convert.ToInt32(User.Identity.Name); if (User.IsInRole("Parent")) { // int userID = Convert.ToInt32(User.Identity.Name); Int32 theUser = Convert.ToInt32(User.Identity.Name); Parent theP = work.ParentRepository.Get(a => a.UserID == theUser).First(); if (studentID != null) { int id = Convert.ToInt32(studentID); PrimarySchoolStudent theStudents = work.PrimarySchoolStudentRepository.GetByID(id); if (theStudents != null) { userId = theStudents.UserID; // work.PrimarySchoolStudentRepository.Get(a=>a.UserID == ids).First(); } else { userId = -1; } } else { userId = -1; } } else { // userID = Convert.ToInt32(User.Identity.Name); userId = Convert.ToInt32(User.Identity.Name); } //int userId = Convert.ToInt32(User.Identity.Name); List <PrimarySchoolStudent> theStaff = work.PrimarySchoolStudentRepository.Get(a => a.UserID == userId).ToList(); List <List <TimeTable> > theTimeTable = new List <List <TimeTable> >(); if (theStaff.Count() > 0) { PrimarySchoolStudent theRealStudent = theStaff[0]; string theArm = theRealStudent.LevelType; theTimeTable = TimeTableCollisionAviodance.DisplayTimeTable(theArm); } // ViewBag.TimeTable = theTimeTable; // ViewBag.Name = theRealStaff.LastName + " " + theRealStaff.FirstName; return(View("Index", theTimeTable)); }
// public ActionResult IndexAsync(string ExamCode = "kababa") public ActionResult Index(string ExamCode = "kababa") { //HttpContext.Server.ScriptTimeout = 888888888; List <OnlineExam> theExam = null; Int32 examStudentUserName = Convert.ToInt32(User.Identity.Name); //List<PrimarySchoolStudent> examStudents = work.PrimarySchoolStudentRepository.Get(a => a.UserID == examStudentUserName).ToList(); //PrimarySchoolStudent examStudent = examStudents[0]; PrimarySchoolStudent examStudent = work.PrimarySchoolStudentRepository.Get(a => a.UserID == examStudentUserName).First(); // PrimarySchoolStudent examStudent = examStudents[0]; //Course theCourse = work.CourseRepository.GetByID(id); if (ExamCode == "kababa") { if (examStudent.ExamWritingNow != null) { theExam = work.OnlineExamRepository.Get(a => a.Visible == "true" && a.LevelName.Equals(examStudent.PresentLevel) && !(a.ExamCode.Equals(examStudent.ExamWritingNow))).ToList(); } else { theExam = work.OnlineExamRepository.Get(a => a.Visible == "true" && a.LevelName.Equals(examStudent.PresentLevel)).ToList(); } // List<Exam> theExam = work.ExamRepository.Get(a => a.LevelName.Equals(level) && a.Term== term && a.Visible== "true").ToList();// && a.CourseID == courseID } else { if (examStudent.ExamWritingNow != null) { theExam = work.OnlineExamRepository.Get(a => a.Visible == "true" && a.ExamCode.Equals(ExamCode) && a.LevelName.Equals(examStudent.PresentLevel) && !(a.ExamCode.Equals(examStudent.ExamWritingNow))).ToList(); } else { theExam = work.OnlineExamRepository.Get(a => a.Visible == "true" && a.ExamCode.Equals(ExamCode) && a.LevelName.Equals(examStudent.PresentLevel)).ToList(); } if (theExam.Count > 0) { Examme = theExam[0]; IList <Question> theQs = new ExamService().GetQuestions(theExam[0]); var rnd = new Random(); IList <Question> theRamdomExam = theQs.OrderBy(x => rnd.Next()).ToList(); IList <Question> theRealRamdomExam = new List <Question>(); int counter = 0; foreach (var q in theRamdomExam) { counter = counter + 1; q.FakeNumber = counter; theRealRamdomExam.Add(q); } // Examme.AddQuestion(theQs); // Examme.AddQuestion(theRamdomExam); Examme.AddQuestion(theRealRamdomExam); } } // if its only a practise exam/test dont update anyfin if ((Examme.ExamType != "Practise" && Examme.ExamType != "PractiseRecord")) { if (examStudent.ExamWritingNow != null && theExam.Count > 0 && ExamCode != "kababa") { if (examStudent.ExamWritingNow.Equals(ExamCode)) { ModelState.AddModelError("", "Becuase you Refreshed(or Pressed the back Button) this page, you are now disqalified from this Exam!"); OnlineExam myFakeExam = new OnlineExam(); return(View(myFakeExam)); } else { //examStudent.ExamWritingNow = ExamCode; //work.PrimarySchoolStudentRepository.Update(examStudent); //work.Save(); int personID = examStudent.PersonID; PrimarySchoolStudent studentEx = work2.PrimarySchoolStudentRepository.GetByID(personID); studentEx.ExamWritingNow = ExamCode; //examStudent.ExamWritingNow = ExamCode; work2.PrimarySchoolStudentRepository.Update(studentEx); work2.Save(); } } if (examStudent.ExamWritingNow == null && theExam.Count > 0 && ExamCode != "kababa") { int personID = examStudent.PersonID; PrimarySchoolStudent studentEx = work2.PrimarySchoolStudentRepository.GetByID(personID); studentEx.ExamWritingNow = ExamCode; //examStudent.ExamWritingNow = ExamCode; work2.PrimarySchoolStudentRepository.Update(studentEx); work2.Save(); } } List <SelectListItem> ExamCodes = new List <SelectListItem>(); foreach (var exam in theExam) { ExamCodes.Add(new SelectListItem() { Text = exam.ExamCode, Value = exam.ExamCode }); } ViewData["ExamCodes"] = ExamCodes; return(View(Examme)); }
public ActionResult Edit(Parent model) { try { work.ParentRepository.Update(model); work.Save(); Parent theParent = work.ParentRepository.GetByID(model.ParentID); int pID = theParent.ParentID; List <PrimarySchoolStudent> thePri = work.PrimarySchoolStudentRepository.Get(a => a.ParentID == pID).ToList(); foreach (PrimarySchoolStudent p in thePri) { p.Parent = null; p.ParentID = null; work.PrimarySchoolStudentRepository.Update(p); } work.Save(); int parentId = model.ParentID; List <PrimarySchoolStudent> theP = new List <PrimarySchoolStudent>(); if (!(string.IsNullOrEmpty(model.StudentIDOne))) { int id = Convert.ToInt32(model.StudentIDOne); List <PrimarySchoolStudent> theStudents = work.PrimarySchoolStudentRepository.Get(a => a.UserID == id).ToList(); PrimarySchoolStudent theStudent = theStudents[0]; if (theStudent != null) { theStudent.ParentID = parentId; work.PrimarySchoolStudentRepository.Update(theStudent); theP.Add(theStudent); } } if (!(string.IsNullOrEmpty(model.StudentIDTwo))) { int id = Convert.ToInt32(model.StudentIDTwo); List <PrimarySchoolStudent> theStudents = work.PrimarySchoolStudentRepository.Get(a => a.UserID == id).ToList(); PrimarySchoolStudent theStudent = theStudents[0]; if (theStudent != null) { theStudent.ParentID = parentId; work.PrimarySchoolStudentRepository.Update(theStudent); theP.Add(theStudent); // model.ThePrimarySchoolStudent. } } if (!(string.IsNullOrEmpty(model.StudentIDThree))) { int id = Convert.ToInt32(model.StudentIDThree); List <PrimarySchoolStudent> theStudents = work.PrimarySchoolStudentRepository.Get(a => a.UserID == id).ToList(); PrimarySchoolStudent theStudent = theStudents[0]; if (theStudent != null) { theStudent.ParentID = parentId; work.PrimarySchoolStudentRepository.Update(theStudent); theP.Add(theStudent); } } if (!(string.IsNullOrEmpty(model.StudentIDFour))) { int id = Convert.ToInt32(model.StudentIDFour); List <PrimarySchoolStudent> theStudents = work.PrimarySchoolStudentRepository.Get(a => a.UserID == id).ToList(); PrimarySchoolStudent theStudent = theStudents[0]; if (theStudent != null) { theStudent.ParentID = parentId; work.PrimarySchoolStudentRepository.Update(theStudent); theP.Add(theStudent); } } if (!(string.IsNullOrEmpty(model.StudentIDFive))) { int id = Convert.ToInt32(model.StudentIDFive); List <PrimarySchoolStudent> theStudents = work.PrimarySchoolStudentRepository.Get(a => a.UserID == id).ToList(); PrimarySchoolStudent theStudent = theStudents[0]; if (theStudent != null) { theStudent.ParentID = parentId; work.PrimarySchoolStudentRepository.Update(theStudent); theP.Add(theStudent); } } if (User.Identity.Name != "5000001") { AuditTrail audit = new AuditTrail { Date = DateTime.Now, Action = "Parent Information Updated User ID:-" + model.UserID, UserID = User.Identity.Name }; work.AuditTrailRepository.Insert(audit); work.Save(); } work.Save(); // TODO: Add update logic here return(RedirectToAction("Index")); } catch { return(View("Edit Parent")); } }
public ActionResult Create(Parent model) { try { List <PrimarySchoolStudent> theP = new List <PrimarySchoolStudent>(); if (!(string.IsNullOrEmpty(model.StudentIDOne))) { int id = Convert.ToInt32(model.StudentIDOne); List <PrimarySchoolStudent> theStudents = work.PrimarySchoolStudentRepository.Get(a => a.UserID == id).ToList(); PrimarySchoolStudent theStudent = theStudents[0]; if (theStudent != null) { theP.Add(theStudent); // model.ThePrimarySchoolStudent. } } if (!(string.IsNullOrEmpty(model.StudentIDTwo))) { int id = Convert.ToInt32(model.StudentIDTwo); List <PrimarySchoolStudent> theStudents = work.PrimarySchoolStudentRepository.Get(a => a.UserID == id).ToList(); PrimarySchoolStudent theStudent = theStudents[0]; if (theStudent != null) { theP.Add(theStudent); // model.ThePrimarySchoolStudent. } } if (!(string.IsNullOrEmpty(model.StudentIDThree))) { int id = Convert.ToInt32(model.StudentIDThree); List <PrimarySchoolStudent> theStudents = work.PrimarySchoolStudentRepository.Get(a => a.UserID == id).ToList(); PrimarySchoolStudent theStudent = theStudents[0]; if (theStudent != null) { theP.Add(theStudent); // model.ThePrimarySchoolStudent. } } if (!(string.IsNullOrEmpty(model.StudentIDFour))) { int id = Convert.ToInt32(model.StudentIDFour); List <PrimarySchoolStudent> theStudents = work.PrimarySchoolStudentRepository.Get(a => a.UserID == id).ToList(); PrimarySchoolStudent theStudent = theStudents[0]; if (theStudent != null) { theP.Add(theStudent); // model.ThePrimarySchoolStudent. } } if (!(string.IsNullOrEmpty(model.StudentIDFive))) { int id = Convert.ToInt32(model.StudentIDFive); List <PrimarySchoolStudent> theStudents = work.PrimarySchoolStudentRepository.Get(a => a.UserID == id).ToList(); PrimarySchoolStudent theStudent = theStudents[0]; if (theStudent != null) { theP.Add(theStudent); // model.ThePrimarySchoolStudent. } } model.ThePrimarySchoolStudent = theP; int theNewID; int theNewUserID; List <Parent> thePerson = work.ParentRepository.Get().ToList(); Int32 totalParents = thePerson.Count(); if (thePerson.Count() == 0) { theNewUserID = 1000;// UserIDLengthAdjuster.NumberAdjuster("1"); } else { Parent Paren = thePerson.Last(); // Paren.UserID; //theNewID = Paren.PersonID + 1; theNewUserID = Paren.UserID + 1;// UserIDLengthAdjuster.NumberAdjuster(theNewID.ToString()); } model.UserID = Convert.ToInt32(theNewUserID); model.Date = DateTime.Now; model.Role = "Parent"; work.ParentRepository.Insert(model); work.Save(); string password = PaddPassword.Padd(model.FirstName.ToLower() + model.MiddleName.ToLower() + model.LastName.ToLower()); Membership.CreateUser(model.UserID.ToString(), password); Roles.AddUserToRole(model.UserID.ToString(), "Parent"); Tweaker.AdjustTimer(model.UserID.ToString()); if (User.Identity.Name != "5000001") { AuditTrail audit = new AuditTrail { Date = DateTime.Now, Action = "A Parent was Created, frist name:-" + " " + model.FirstName + " " + "Last Name :- " + model.LastName, UserID = User.Identity.Name }; work.AuditTrailRepository.Insert(audit); work.Save(); } return(RedirectToAction("Index")); //} //else //{ // return View("Create Parent"); //} } catch { return(View()); } }
public ActionResult Edit(StaffViewModel viewmodel, string classteacher1, string classteacher2, string classteacher3, string classteacher4) { PrimarySchoolStaff model = viewmodel.PrimarySchoolStaff; try { // TODO: Add update logic here // model.EnrollmentDate = DateTime.Now; StringBuilder theContributionId = new StringBuilder(); if (viewmodel.Deductions.Count > 0) { List <Deduction> theDec = new List <Deduction>(); foreach (Deduction d in viewmodel.Deductions) { if (d.Selected == true) { // List<PrimarySchoolStaff> theS = new List<PrimarySchoolStaff>(); // theS.Add(model); // d.ThePrimarySchoolStaff = theS; theContributionId.Append(d.DeductionID); theContributionId.Append(' '); theDec.Add(d); } } model.ContributionIDs = theContributionId.ToString(); model.TheDeduction = theDec; // theDec[0]. // TheDeduction[0]. // model.TheDeduction } // PrimarySchoolStaff model = viewmodel.PrimarySchoolStaff; if (ModelState.IsValid) { model.ClassTeacherOf = model.ClassTeacherOf + "-" + classteacher1 + "-" + classteacher2 + "-" + classteacher3 + "-" + classteacher4; // PrimarySchoolStudent theStudent = work.PrimarySchoolStudentRepository.GetByID(model.PersonID); if (model.IsApproved == true) { MembershipUser user = Membership.GetUser(Convert.ToString(5000000 + model.PersonID), false);; if (user == null) { //if (Membership.FindUsersByName(Convert.ToString(5000000 + model.PersonID)) == null) //{ model.UserID = 5000000 + model.PersonID; // model.level model.DateApproved = DateTime.Now; model.IsApproved = true; string password = PaddPassword.Padd(model.FirstName.ToLower() + model.Middle.ToLower() + model.LastName.ToLower()); Membership.CreateUser(model.UserID.ToString(), password, model.Email); // var user = _userService.Get(id); Tweaker.AdjustTimer(model.UserID.ToString()); Roles.AddUserToRole(model.UserID.ToString(), model.Role); } else { PrimarySchoolStaff staff = work2.PrimarySchoolStaffRepository.GetByID(model.PersonID); string[] RoleList = Roles.GetAllRoles(); // Roles.RemoveUserFromRoles(model.UserID.ToString(), RoleList); foreach (var role in RoleList) { if (Roles.IsUserInRole(model.UserID.ToString(), role)) { Roles.RemoveUserFromRole(model.UserID.ToString(), role); } } Roles.AddUserToRole(model.UserID.ToString(), model.Role); work.PrimarySchoolStaffRepository.Update(model); Tweaker.AdjustTimer(model.UserID.ToString()); } } //foreach (Deduction d in model.TheDeduction) //{ // work.DeductionRepository.Update(d); //} // work.DeductionRepository. work.PrimarySchoolStaffRepository.Update(model); work.Save(); if (User.Identity.Name != "5000001") { AuditTrail audit = new AuditTrail { Date = DateTime.Now, Action = "Staff Information Updated, Staff ID:-" + model.UserID, UserID = User.Identity.Name }; work.AuditTrailRepository.Insert(audit); work.Save(); } } return(RedirectToAction("Index")); } catch { PrimarySchoolStudent theStudent = work.PrimarySchoolStudentRepository.GetByID(model.PersonID); string thKeyRole = theStudent.Role; List <SelectListItem> theItem3 = new List <SelectListItem>(); List <MyRole> theRoles = work.MyRoleRepository.Get().ToList(); theItem3.Add(new SelectListItem() { Text = thKeyRole, Value = thKeyRole }); foreach (var role in theRoles) { // if (theStudent.Role.Equals(role.RoleName)) // { // theItem3.Add(new SelectListItem() { Selected = true, Text = role.RoleName, Value = role.RoleName }); // } // else // { if (role.RoleName != null && role.RoleName != "Student") { string thRole = role.RoleName.Trim(); //theItem3.Add(new SelectListItem() { Text = role.RoleName, Value = role.RoleName }); theItem3.Add(new SelectListItem() { Text = thRole, Value = thRole }); // } } } ViewBag.Role = theItem3; // ViewData["Role"] = theItem3; List <Level> theLevels = work.LevelRepository.Get().ToList(); List <SelectListItem> theItem = new List <SelectListItem>(); theItem.Add(new SelectListItem() { Text = "Not Applicable", Value = "Not Applicable" }); theItem.Add(new SelectListItem() { Text = "Proprietor", Value = "Proprietor" }); theItem.Add(new SelectListItem() { Text = "Principal", Value = "Principal" }); theItem.Add(new SelectListItem() { Text = "Bursar", Value = "Bursar" }); theItem.Add(new SelectListItem() { Text = "Admin Secretary", Value = "Admin Secretary" }); theItem.Add(new SelectListItem() { Text = "Supervisor", Value = "Supervisor" }); theItem.Add(new SelectListItem() { Text = "Vice Principal", Value = "Vice Principal" }); theItem.Add(new SelectListItem() { Text = "Head Teacher", Value = "Head Teache" }); theItem.Add(new SelectListItem() { Text = "Administrator", Value = "Administrator" }); theItem.Add(new SelectListItem() { Text = "Store Man", Value = "Store Man" }); theItem.Add(new SelectListItem() { Text = "Librarian", Value = "Librarian" }); theItem.Add(new SelectListItem() { Text = "Lab Attendant", Value = "Lab Attendant" }); theItem.Add(new SelectListItem() { Text = "Subject Teacher", Value = "Subject Teacher" }); theItem.Add(new SelectListItem() { Text = "Clerk", Value = "Clerk" }); theItem.Add(new SelectListItem() { Text = "Receptionist", Value = "Receptionist" }); theItem.Add(new SelectListItem() { Text = "Caregiver", Value = "Caregiver" }); theItem.Add(new SelectListItem() { Text = "Minder", Value = "Minder" }); theItem.Add(new SelectListItem() { Text = "Cleaner", Value = "Cleaner" }); theItem.Add(new SelectListItem() { Text = "Class Assistant", Value = "Class Assistant" }); foreach (var level in theLevels) { theItem.Add(new SelectListItem() { Text = level.LevelName + ":" + level.Type, Value = level.LevelName + ":" + level.Type }); } ViewData["Level"] = theItem; List <SelectListItem> theSubjectList = new List <SelectListItem>(); List <Subject> theSubject = work.SubjectRepository.Get().ToList(); theSubjectList.Add(new SelectListItem() { Text = "Not Applicable", Value = "Not Applicable" }); foreach (var subject in theSubject) { theSubjectList.Add(new SelectListItem() { Text = subject.Name, Value = subject.Name }); } ViewData["Subject"] = theSubjectList; //List<LatenessDeduction> theLatenessDeduction = work.LatenessDeductionRepository.Get().ToList(); List <SelectListItem> theLatenessDeductionListItem = new List <SelectListItem>(); theLatenessDeductionListItem.Add(new SelectListItem() { Text = "None", Value = "" }); theLatenessDeductionListItem.Add(new SelectListItem() { Text = "YES", Value = "true" }); theLatenessDeductionListItem.Add(new SelectListItem() { Text = "NO", Value = "false" }); ViewData["LatenessDeduction"] = theLatenessDeductionListItem; List <SelectListItem> theAbscentDeductionListItem = new List <SelectListItem>(); theAbscentDeductionListItem.Add(new SelectListItem() { Text = "None", Value = "" }); theAbscentDeductionListItem.Add(new SelectListItem() { Text = "YES", Value = "true" }); theAbscentDeductionListItem.Add(new SelectListItem() { Text = "NO", Value = "false" }); ViewData["AbscentDeduction"] = theAbscentDeductionListItem; //salary List <SelectListItem> theSalaryList = new List <SelectListItem>(); List <Salary> theSalary = work.SalaryRepository.Get().ToList(); theSalaryList.Add(new SelectListItem() { Text = "Select", Value = "" }); foreach (var s in theSalary) { theSalaryList.Add(new SelectListItem() { Text = s.SalaryDescription + " Amount(NGN) " + s.Amount, Value = Convert.ToString(s.SalaryID) }); } ViewData["salary"] = theSalaryList; StaffViewModel theStaff = new StaffViewModel(); List <Deduction> theDeductions = work.DeductionRepository.Get().ToList(); theStaff.Deductions = theDeductions; return(View(theStaff)); } }
public ActionResult ViewYourFees(string id, string term, string TheSchoolFeesType, string session) { string theTerm = ""; if (term == "1") { theTerm = "First"; ViewBag.Term = "First"; } if (term == "2") { theTerm = "Second"; ViewBag.Term = "Second"; } if (term == "3") { theTerm = "Third"; ViewBag.Term = "Third"; } ViewBag.session = session; ViewBag.ParentStudent = "ParentStudent"; Int32 stuentID = Convert.ToInt32(Models.Encript.DecryptString(id, true)); TermRegistration theTermRegistration = new TermRegistration(); List <TermRegistration> theTermRegistrations = work.TermRegistrationRepository.Get(a => a.Session == session && a.Term == theTerm && a.StudentID == stuentID).ToList(); // List<TermRegistration> theTermRegistrations = work.TermRegistrationRepository.Get(a => a.Session == session && a.Term == theTerm && a.StudentID == stuentID).ToList(); List <SchoolFeePayment> theStudentFeesPaymentLast10Transactions = work.SchoolFeePaymentRepository.Get(a => a.StudentID == stuentID).OrderByDescending(a => a.DatePaid).Take(10).OrderBy(a => a.DatePaid).ToList(); ViewBag.Last10Transactions = theStudentFeesPaymentLast10Transactions; if (theTermRegistrations.Count() > 0) { theTermRegistration = theTermRegistrations[0]; ViewBag.TermRegistration = theTermRegistration; ViewBag.TheSchoolFeesType = theTermRegistration.SchoolFeesKind; ViewBag.session = theTermRegistration.Session; //theTermRegistration.Cost = PrimarySchoolStudent theStudent = work.PrimarySchoolStudentRepository.Get(a => a.UserID == stuentID).First(); ViewBag.Class = theStudent.LevelType; ViewBag.Name = theStudent.LastName.ToUpper(); //List<SchoolFeePayment> theStudentFeesPayment = work.SchoolFeePaymentRepository.Get(a => a.StudentID == theStudent.UserID && a.Level.Equals(theStudent.PresentLevel) && a.Term.Equals(term)).ToList(); List <SchoolFeePayment> theStudentFeesPayment = work.SchoolFeePaymentRepository.Get(a => a.StudentID == theStudent.UserID).OrderBy(a => a.DatePaid).Take(20).ToList(); List <SchoolFeePayment> theStudentFeesForThisStudentPayment = work.SchoolFeePaymentRepository.Get(a => a.StudentID == theStudent.UserID && a.Session == session && a.Term == theTerm).OrderBy(a => a.DatePaid).Take(10).ToList(); //check if the student is owing for current term List <SchoolFeePayment> theStudentFeesForStudentPaymentForThisTerm = work.SchoolFeePaymentRepository.Get(a => a.StudentID == theStudent.UserID && a.Session == session && a.Term == theTerm).OrderByDescending(a => a.DatePaid).ToList(); // List<TermRegistration> theLastStudentRegistration = work.TermRegistrationRepository.Get(a=>a.) //ViewData["SchoolFeesKind"] = theItem; List <SchoolFeePayment> owingPayment = new List <SchoolFeePayment>(); decimal totalOwing = 0; // foreach (SchoolFeePayment s in theStudentFeesPayment) // if (theStudentFeesPayment.Count > 0) if (theStudentFeesForStudentPaymentForThisTerm.Count > 0) { // SchoolFeePayment p = theStudentFeesPayment.OrderByDescending(a => a.DatePaid).First(); SchoolFeePayment p = theStudentFeesForStudentPaymentForThisTerm.OrderByDescending(a => a.DatePaid).First(); totalOwing = p.Owing; if (totalOwing > 0) { owingPayment.Add(p); } } ViewBag.totalOwing = totalOwing; ViewBag.Last10Transaction = theStudentFeesForThisStudentPayment; ViewBag.theCurrentTermPayment = theStudentFeesForThisStudentPayment.Count(); ViewBag.Cost = theTermRegistration.Cost;// theType.Amount; ViewBag.Owing = owingPayment; return(View("Edit", new SchoolFeePayment() { Level = theStudent.PresentLevel, StudentID = theStudent.UserID, Term = term })); } else { return(View("Edit")); } }
public ViewResult Index2(string sortOrder, string currentFilter, string Date, int?page, string studentID) // public ActionResult Index2() { if (User.IsInRole("Parent")) { Int32 theUser = Convert.ToInt32(User.Identity.Name); List <PrimarySchoolStudent> thSchoolStudents; // string userid = User.Identity.Name; List <Parent> theP = work.ParentRepository.Get(a => a.UserID == theUser).ToList(); Parent theRealParent = theP[0]; int idParent = theRealParent.ParentID; thSchoolStudents = work.PrimarySchoolStudentRepository.Get(a => a.ParentID == idParent).ToList(); List <SelectListItem> theItem = new List <SelectListItem>(); // theItem.Add(new SelectListItem() { Text = "None", Value = "" }); foreach (var s in thSchoolStudents) { theItem.Add(new SelectListItem() { Text = s.LastName + " " + s.FirstName, Value = s.PersonID.ToString() }); ViewData["Students"] = theItem; } } List <Order> theOrders = new List <Order>(); if (User.IsInRole("Parent")) { Int32 theUser = Convert.ToInt32(User.Identity.Name); Parent theP = work.ParentRepository.Get(a => a.UserID == theUser).First(); if (studentID != null) { int id = Convert.ToInt32(studentID); PrimarySchoolStudent theStudent = work.PrimarySchoolStudentRepository.GetByID(id); if (theStudent != null) { theOrders = work.OrderRepository.Get().OrderByDescending(a => a.OrderDate).ToList(); theOrders = theOrders.Where(a => a.studentID == theStudent.UserID).ToList(); } else { theOrders = theOrders.Where(a => a.studentID == 0).ToList(); } } else { theOrders = theOrders.Where(a => a.studentID == 0).ToList(); } } else { int student = Convert.ToInt32(User.Identity.Name); theOrders = work.OrderRepository.Get(a => a.studentID == student).OrderByDescending(a => a.OrderDate).ToList(); } if (!String.IsNullOrEmpty(Date)) { DateTime d = Convert.ToDateTime(Date); theOrders = theOrders.Where(s => s.OrderDate.Value.Date == d.Date).ToList(); } int pageSize = 50; int pageNumber = (page ?? 1); return(View(theOrders.ToPagedList(pageNumber, pageSize))); }
public ActionResult Grade(OnlineExam exam) { if (exam.Questions.Count == 0) { // RedirectToAction("Index"); return(View("Error")); } else { var grade = new ExamService().Grade(exam); Question theQuestion = work.QuestionRepository.GetByID(exam.Questions[0].QuestionID); OnlineExam theOnlineExam = work.OnlineExamRepository.GetByID(theQuestion.OnlineExamID); //get user who has just finished the exam Int32 UserName = Convert.ToInt32(User.Identity.Name); List <PrimarySchoolStudent> theStudents = work.PrimarySchoolStudentRepository.Get(a => a.UserID == UserName).ToList(); PrimarySchoolStudent theStudent = theStudents[0]; if (theOnlineExam.ExamType == "PractiseRecord") { string theUserID = Convert.ToString(theStudent.UserID); List <PractiseSave> thePractice = work.PractiseSaveRepository.Get(a => a.Term.Equals(theOnlineExam.Term) && a.Code.Equals(theOnlineExam.ExamCode) && a.StudentID.Equals(theUserID)).ToList(); //Check if there is not an exam code equal to this one if (thePractice.Count == 0) { PractiseSave theStudentScore = new PractiseSave(); double e = ((grade.Score / grade.TotalPoints) * 100); theStudentScore.Score = Convert.ToDecimal(e); theStudentScore.Level = theStudent.PresentLevel; theStudentScore.StudentID = Convert.ToString(theStudent.UserID); theStudentScore.Subject = theOnlineExam.Course; theStudentScore.Term = theOnlineExam.Term; theStudentScore.Code = theOnlineExam.ExamCode; theStudentScore.LevelType = theStudent.LevelType; // theStudentScore. work.PractiseSaveRepository.Insert(theStudentScore); work.Save(); } } if (theOnlineExam.ExamType == "Exam" || theOnlineExam.ExamType == "TEST 1" || theOnlineExam.ExamType == "TEST 2") { //if student has no repeat if (theStudent.RepeatTimes == 0) { List <Exam> theExam0 = work.ExamRepository.Get(a => a.StudentCode == theStudent.UserID && a.Level.Equals(theStudent.PresentLevel) && a.SubjectName.Equals(theOnlineExam.Course) && a.Term.Equals(theOnlineExam.Term)).ToList(); // if (theOnlineExam.ExamType == "Exam") { if (theExam0.Count > 0) { // if(theExam0) Exam theStudentScore = theExam0[0]; if (theStudentScore.SubjectExam == 0) { double e = ((grade.Score / grade.TotalPoints) * 100) * 0.6; theStudentScore.SubjectExam = Convert.ToDecimal(e); work2.ExamRepository.Update(theStudentScore); work2.Save(); } } else { Exam theStudentScore = new Exam(); theStudentScore.Term = theOnlineExam.Term; theStudentScore.SubjectName = theOnlineExam.Course; theStudentScore.Level = theStudent.PresentLevel; theStudentScore.StudentCode = theStudent.UserID; double e = ((grade.Score / grade.TotalPoints) * 100) * 0.6; theStudentScore.SubjectExam = Convert.ToDecimal(e); work2.ExamRepository.Insert(theStudentScore); work2.Save(); } } if (theOnlineExam.ExamType == "TEST 1") { if (theExam0.Count > 0) { Exam theStudentScore = theExam0[0]; if (theStudentScore.FirstCA == 0) { double t2 = ((grade.Score / grade.TotalPoints) * 100) * 0.2; theStudentScore.FirstCA = Convert.ToDecimal(t2); work2.ExamRepository.Update(theStudentScore); work2.Save(); } } else { double t1 = ((grade.Score / grade.TotalPoints) * 100) * 0.2; Exam theExam = new Exam(); theExam.FirstCA = Convert.ToDecimal(t1); theExam.Term = theOnlineExam.Term; theExam.SubjectName = theOnlineExam.Course; theExam.Level = theStudent.PresentLevel; theExam.StudentCode = theStudent.UserID; // theStudentScore.FirstCA = work2.ExamRepository.Insert(theExam); work2.Save(); } } if (theOnlineExam.ExamType == "TEST 2") { if (theExam0.Count > 0) { Exam theStudentScore = theExam0[0]; if (theStudentScore.SecondCA == 0) { double t2 = ((grade.Score / grade.TotalPoints) * 100) * 0.2; theStudentScore.SecondCA = Convert.ToDecimal(t2); work2.ExamRepository.Update(theStudentScore); work2.Save(); } } else { if (theOnlineExam.ExamType == "TEST 2") { double t1 = ((grade.Score / grade.TotalPoints) * 100) * 0.2; Exam theExam = new Exam(); theExam.SecondCA = Convert.ToDecimal(t1); theExam.Term = theOnlineExam.Term; theExam.SubjectName = theOnlineExam.Course; theExam.Level = theStudent.PresentLevel; theExam.StudentCode = theStudent.UserID; // theStudentScore.FirstCA = work2.ExamRepository.Insert(theExam); work2.Save(); //Exam theStudentScore = theExam0[0]; //double t2 = ((grade.Score / grade.TotalPoints) * 100) * 0.3; //theStudentScore.SecondCA = Convert.ToDecimal(t2); //work2.ExamRepository.Update(theStudentScore); //work2.Save(); } } } } //check for repeat 1 if (theStudent.RepeatTimes == 1) { List <Exam1> theExam1 = work.Exam1Repository.Get(a => a.StudentCode == theStudent.UserID && a.Level.Equals(theStudent.PresentLevel) && a.SubjectName.Equals(theOnlineExam.Course) && a.Term.Equals(theOnlineExam.Term)).ToList(); // if (theOnlineExam.ExamType == "Exam") { if (theExam1.Count > 0) { Exam1 theStudentScore = theExam1[0]; if (theStudentScore.SubjectExam == 0) { double e = ((grade.Score / grade.TotalPoints) * 100) * 0.6; theStudentScore.SubjectExam = Convert.ToDecimal(e); work2.Exam1Repository.Update(theStudentScore); work2.Save(); } } else { if (theOnlineExam.ExamType == "Exam") { Exam1 theStudentScore = new Exam1(); theStudentScore.Term = theOnlineExam.Term; theStudentScore.SubjectName = theOnlineExam.Course; theStudentScore.Level = theStudent.PresentLevel; theStudentScore.StudentCode = theStudent.UserID; double e = ((grade.Score / grade.TotalPoints) * 100) * 0.6; theStudentScore.SubjectExam = Convert.ToDecimal(e); work2.Exam1Repository.Insert(theStudentScore); work2.Save(); //Exam1 theStudentScore = new Exam1(); //theStudentScore.SecondCA = 0.00M; //double e = ((grade.Score / grade.TotalPoints) * 100) * 0.5; //// theStudentScore.SubjectExam = e; //theStudentScore.SubjectExam = Convert.ToDecimal(e); //work2.Exam1Repository.Insert(theStudentScore); //work2.Save(); } } } if (theOnlineExam.ExamType == "TEST 1") { if (theExam1.Count > 0) { Exam1 theStudentScore = theExam1[0]; if (theStudentScore.FirstCA == 0) { double t2 = ((grade.Score / grade.TotalPoints) * 100) * 0.2; theStudentScore.FirstCA = Convert.ToDecimal(t2); work2.Exam1Repository.Update(theStudentScore); work2.Save(); } } else { double t1 = ((grade.Score / grade.TotalPoints) * 100) * 0.2; Exam1 theExamlocal1 = new Exam1(); theExamlocal1.FirstCA = Convert.ToDecimal(t1); theExamlocal1.Term = theOnlineExam.Term; theExamlocal1.SubjectName = theOnlineExam.Course; theExamlocal1.Level = theStudent.PresentLevel; theExamlocal1.StudentCode = theStudent.UserID; // theStudentScore.FirstCA = work2.Exam1Repository.Insert(theExamlocal1); work2.Save(); } } if (theExam1.Count > 0) { if (theOnlineExam.ExamType == "TEST 2") { Exam1 theStudentScore = theExam1[0]; if (theStudentScore.SecondCA == 0) { double t2 = ((grade.Score / grade.TotalPoints) * 100) * 0.2; theStudentScore.SecondCA = Convert.ToDecimal(t2); work2.Exam1Repository.Update(theStudentScore); work2.Save(); } } } else { if (theOnlineExam.ExamType == "TEST 2") { double t1 = ((grade.Score / grade.TotalPoints) * 100) * 0.2; Exam1 theExam = new Exam1(); theExam.SecondCA = Convert.ToDecimal(t1); theExam.Term = theOnlineExam.Term; theExam.SubjectName = theOnlineExam.Course; theExam.Level = theStudent.PresentLevel; theExam.StudentCode = theStudent.UserID; // theStudentScore.FirstCA = work2.Exam1Repository.Insert(theExam); work2.Save(); } } } //check for repeat 2 if (theStudent.RepeatTimes == 2) { List <Exam2> theExam2 = work.Exam2Repository.Get(a => a.StudentCode == theStudent.UserID && a.Level.Equals(theStudent.PresentLevel) && a.SubjectName.Equals(theOnlineExam.Course) && a.Term.Equals(theOnlineExam.Term)).ToList(); // if (theOnlineExam.ExamType == "Exam") { if (theExam2.Count > 0) { Exam2 theStudentScore = theExam2[0]; if (theStudentScore.SubjectExam == 0) { double e = ((grade.Score / grade.TotalPoints) * 100) * 0.6; theStudentScore.SubjectExam = Convert.ToDecimal(e); work2.Exam2Repository.Update(theStudentScore); work2.Save(); } } else { if (theOnlineExam.ExamType == "Exam") { Exam2 theStudentScore = new Exam2(); theStudentScore.Term = theOnlineExam.Term; theStudentScore.SubjectName = theOnlineExam.Course; theStudentScore.Level = theStudent.PresentLevel; theStudentScore.StudentCode = theStudent.UserID; double e = ((grade.Score / grade.TotalPoints) * 100) * 0.6; theStudentScore.SubjectExam = Convert.ToDecimal(e); work2.Exam2Repository.Insert(theStudentScore); work2.Save(); //Exam2 theStudentScore = new Exam2(); //theStudentScore.SecondCA = 0.00M; //double e = ((grade.Score / grade.TotalPoints) * 100) * 0.5; //// theStudentScore.SubjectExam = e; //theStudentScore.SubjectExam = Convert.ToDecimal(e); //work2.Exam2Repository.Insert(theStudentScore); //work2.Save(); } } } if (theOnlineExam.ExamType == "TEST 1") { if (theExam2.Count == 0) { double t1 = ((grade.Score / grade.TotalPoints) * 100) * 0.2; Exam2 theExamlocal2 = new Exam2(); theExamlocal2.FirstCA = Convert.ToDecimal(t1); theExamlocal2.Term = theOnlineExam.Term; theExamlocal2.SubjectName = theOnlineExam.Course; theExamlocal2.Level = theStudent.PresentLevel; theExamlocal2.StudentCode = theStudent.UserID; // theStudentScore.FirstCA = work2.Exam2Repository.Insert(theExamlocal2); work2.Save(); } else { Exam2 theStudentScore = theExam2[0]; if (theStudentScore.FirstCA == 0) { double t2 = ((grade.Score / grade.TotalPoints) * 100) * 0.2; theStudentScore.FirstCA = Convert.ToDecimal(t2); work2.Exam2Repository.Update(theStudentScore); work2.Save(); } } } if (theOnlineExam.ExamType == "TEST 2") { if (theExam2.Count > 0) { Exam2 theStudentScore = theExam2[0]; if (theStudentScore.SecondCA == 0) { double t2 = ((grade.Score / grade.TotalPoints) * 100) * 0.2; theStudentScore.SecondCA = Convert.ToDecimal(t2); work2.Exam2Repository.Update(theStudentScore); work2.Save(); } } else { if (theOnlineExam.ExamType == "TEST 2") { double t1 = ((grade.Score / grade.TotalPoints) * 100) * 0.2; Exam2 theExam = new Exam2(); theExam.SecondCA = Convert.ToDecimal(t1); theExam.Term = theOnlineExam.Term; theExam.SubjectName = theOnlineExam.Course; theExam.Level = theStudent.PresentLevel; theExam.StudentCode = theStudent.UserID; // theStudentScore.FirstCA = work2.Exam2Repository.Insert(theExam); work2.Save(); } } } } } return(View(grade)); } //return View(); }