public ActionResult HomeworkApproval(int ID, string C_Code, string title) { homework_request HwReqObject = cx.homework_request.FirstOrDefault(x => x.ID == ID && x.title == title && x.C_Code == C_Code); HomeworkMaker HwObject = new HomeworkMaker(); HwObject.C_Code = HwReqObject.C_Code; HwObject.img = HwReqObject.img; HwObject.price = HwReqObject.price; HwObject.ID = HwReqObject.ID; HwObject.descrip = HwReqObject.descrip; HwObject.title = title; string Message = "Your offer has been accepted for the homework " + C_Code; EmailSend(ID, Message, "Offer status Change"); try { cx.homework_request.Remove(HwReqObject); cx.HomeworkMakers.Add(HwObject); cx.SaveChanges(); TempData["Message"] = "Changed has been saved."; } catch { TempData["Message"] = "Failed, Try again alter"; } return(RedirectToAction("HomeworksPending")); }
public ActionResult HwDeletion(int ID, string C_Code, string title) { homework_request HwReqObject = cx.homework_request.FirstOrDefault(x => x.ID == ID && x.title == title && x.C_Code == C_Code); string Message = "Your offer has been rejectred for the homework " + C_Code + "with the title " + title; EmailSend(ID, Message, "Offer status Change"); try { cx.homework_request.Remove(HwReqObject); cx.SaveChanges(); TempData["Message"] = "Item has been deleted"; } catch { TempData["Message"] = "Failed to delete the item"; } return(RedirectToAction("HomeworksPending")); }
public ActionResult Homework_Req(string C_Code, string title, string C_Name, string dept, string descrip, int price, HttpPostedFileBase img, HttpPostedFileBase transcript) { try { byte[] imageByte = img != null?ChangeImgeToArray(img) : null; Homework HomeworkObject = new Homework(); User usrObejct = ctx.Users.FirstOrDefault(x => x.mail == User.Identity.Name); if (transcript != null) { byte[] TranscriptByte = ChangeImgeToArray(transcript); usrObejct.transcript = TranscriptByte; } if (ctx.homework_request.Any(x => x.ID == usrObejct.id && x.C_Code == C_Code && x.title == title)) { TempData["shortMessage"] = "You have already sent a request, Please be patient."; return(RedirectToAction("HomeworkOfferPage", new { mail = User.Identity.Name })); } if (C_Name != C_Code) { Course CourseObject = new Course(); CourseObject.C_Code = C_Code; CourseObject.C_Name = C_Name; CourseObject.dept = dept; ctx.Courses.Add(CourseObject); ctx.SaveChanges(); } if (!ctx.Homework.Any(x => x.title == title && x.C_Code == C_Code)) { HomeworkObject.title = title; HomeworkObject.C_Code = C_Code; ctx.Homework.Add(HomeworkObject); ctx.SaveChanges(); } homework_request HWObject = new homework_request(); HWObject.C_Code = C_Code; HWObject.descrip = descrip; HWObject.ID = usrObejct.id; HWObject.img = imageByte; HWObject.title = title; HWObject.price = price; ctx.homework_request.Add(HWObject); ctx.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("HomeworkOfferPage", new { mail = User.Identity.Name })); }