public ActionResult CourseApproval(int ID, string C_Code) { lec_request LecReqObject = cx.lec_request.FirstOrDefault(x => x.ID == ID && x.C_Code == C_Code); Lecturer LecObject = new Lecturer(); LecObject.C_Code = LecReqObject.C_Code; LecObject.descrip = LecReqObject.descrip; LecObject.ID = LecReqObject.ID; LecObject.Price = LecReqObject.price; LecObject.img = LecReqObject.img; string Message = "Your offer has been accepted for the course" + C_Code; EmailSend(ID, Message, "Offer status Change"); try { cx.lec_request.Remove(LecReqObject); cx.Lecturers.Add(LecObject); cx.SaveChanges(); TempData["Message"] = "Changes has been saved"; } catch { TempData["Message"] = "Failed, Try again alter"; } return(RedirectToAction("PendingCourses")); }
public ActionResult Course_Req(string C_Code, string C_Name, string dept, string descrip, int price, HttpPostedFileBase img, HttpPostedFileBase transcript) { try { byte[] imageByte = img != null?ChangeImgeToArray(img) : null; User usrObject = cx.Users.FirstOrDefault(x => x.mail == User.Identity.Name); if (cx.lec_request.Any(x => x.ID == usrObject.id && x.C_Code == C_Code)) // in case already has a request { TempData["shortMessage"] = "You have already sent a request, Please be patient."; return(RedirectToAction("CourseOfferPage", new { mail = User.Identity.Name })); } if (usrObject.transcript == null) { if (transcript == null) { TempData["shortMessage"] = "Please upload your transcript."; return(RedirectToAction("CourseOfferPage", new { mail = User.Identity.Name })); } byte[] TranscriptImg = ChangeImgeToArray(transcript); usrObject.transcript = TranscriptImg; } if (C_Name != C_Code) // a new course will be added if this case is true { Course CourseObject = new Course(); CourseObject.C_Code = C_Code; CourseObject.C_Name = C_Name; CourseObject.dept = dept; cx.Courses.Add(CourseObject); } lec_request LecObject = new lec_request(); LecObject.ID = usrObject.id; LecObject.C_Code = C_Code; LecObject.img = imageByte; LecObject.price = price; LecObject.descrip = descrip; cx.lec_request.Add(LecObject); cx.SaveChanges(); TempData["shortMessage"] = "Your request has been sent, the admins will check and get back to you."; } catch { TempData["shortMessage"] = "Your request has not been sent, Please try again later"; } return(RedirectToAction("CourseOfferPage", new { mail = User.Identity.Name })); }
public ActionResult CourseDeletion(int ID, string C_Code) { lec_request LecReqObject = cx.lec_request.FirstOrDefault(x => x.ID == ID && x.C_Code == C_Code); string Message = "Your offer has been rejectred for the course " + C_Code; EmailSend(ID, Message, "Offer status Change"); try { cx.lec_request.Remove(LecReqObject); cx.SaveChanges(); TempData["Message"] = "Item has been deleted"; } catch { TempData["Message"] = "Failed to delete the item"; } return(RedirectToAction("PendingCourses")); }