public ActionResult Insert(int CourseId, string ApplicationUserId, int CategoryId, string TuteeName, string TuteeEmail, string TuteePhone, double AssignmentTotal, bool FollowUp, string Comments = null) { try { Tigbur tigbur = new Tigbur() { TuteeName = TuteeName, TuteeEmail = TuteeEmail, TuteePhone = TuteePhone, ApplicationUserId = ApplicationUserId, CourseId = CourseId, CategoryId = CategoryId, AssignmentStartDate = DateTime.Today, AssignmentEndDate = DateTime.Today.AddMonths(1), AssignmentTotal = AssignmentTotal, AssignmentDone = 0, AssignmentDoneApproved = 0, FollowUp = FollowUp, Comments = Comments }; db.Tigburs.Add(tigbur); db.SaveChanges(); return(RedirectToAction("Index")); } catch (DataException dex) { //Log the error (uncomment dex variable name and add a line here to write a log. ViewBag.errorMessage = dex.Message; return(RedirectToAction("Error")); } }
public async Task <ActionResult> DeleteConfirmed(int id) { Tigbur tigbur = await db.Tigburs.FindAsync(id); db.Tigburs.Remove(tigbur); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> UpdateTigbur([Bind(Include = "Id,CourseId,ApplicationUserId,CategoryId,TuteeName,TuteeEmail,TuteePhone,AssignmentStartDate,AssignmentEndDate,AssignmentTotal,AssignmentDone,AssignmentDoneApproved,FollowUp,Comments")] Tigbur tigbur) { if (ModelState.IsValid) { db.Entry(tigbur).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(tigbur)); }
public async Task <ActionResult> Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Tigbur tigbur = await db.Tigburs.FindAsync(id); if (tigbur == null) { return(HttpNotFound()); } return(View(tigbur)); }
/// <summary> /// method set TempData["ApplicationUserId"] to selectedCourse Value for to save the selected Tuter for the UpdateTigbur ActionResult. /// The method calls the PopulateCategorysDropDownList method without setting the selected item, because for a new Category is not established yet. /// method calls Edit View to input Edit data on the tigbur. /// on submit UpdateTigbur ActionResult is called to Update the tigbur to the database. /// </summary> /// <param name="tigbur"></param> /// <returns></returns> /// public ActionResult Edit(Tigbur tigbur) { if (tigbur == null) { return(HttpNotFound()); } TempData["ApplicationUserId"] = tigbur.ApplicationUserId; var Tutor = db.Users.Find(tigbur.ApplicationUserId); TempData["ApplicationUserName"] = Tutor.Name; PopulateCategorysDropDownList(); return(View(tigbur)); }
/// <summary> /// method get as parameter tigbur model if no tigbur was receivedis return HttpNotFound. /// method set TempData["CourseId"] to selectedCourse Value for to save the selected Course for the Edit ActionResult. /// The method calls the PopulateTutorsDropDownListByValue. /// method calls SelectTutorForEdit View to select a Tutor to the Edit tigbur. /// on View submit the Edit ActionResult is called. /// </summary> /// <param name="tigbur"></param> /// <returns></returns> public ActionResult SelectTutorForEdit(Tigbur tigbur) { if (tigbur == null) { return(HttpNotFound()); } TempData["CourseId"] = tigbur.CourseId; var course = db.Courses.Find(tigbur.CourseId); TempData["CourseName"] = course.Name; PopulateTutorsDropDownListByValue(tigbur.CourseId); return(View(tigbur)); }
/// <summary> /// method get as parameter tigbur id and search in database for the tigbur, if no tigbur is found return HttpNotFound. /// The method calls the PopulateCoursesDropDownList method with setting the selected item as tigbur.CourseId. /// method calls SelectCourseForEdit View to select a course to the Edit tigbur. /// on View submit the SelectTutorForEdit ActionResult is called. /// </summary> /// <param name="id"></param> /// <returns></returns> public async Task <ActionResult> SelectCourseForEdit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Tigbur tigbur = await db.Tigburs.FindAsync(id); if (tigbur == null) { return(HttpNotFound()); } PopulateCoursesDropDownList(tigbur.CourseId); return(View(tigbur)); }