// // GET: /Teacher/Create public ActionResult Create() { var teacher = new Teacher(); teacher.Init(); foreach (var course in Academy.Current.Courses) { teacher.CmbCourse.Add(new SelectListItem() { Text = course.Name, Value = course.Id + "" }); } return View(teacher); }
// PUT: api/Teachers/5 public async Task<IHttpActionResult> PutTeacher(int id, Teacher Teacher) { var TeacherFromPersist = _context.Teachers.FirstOrDefault(item => item.Id == id); if (TeacherFromPersist == null) return NotFound(); TeacherFromPersist.Name = Teacher.Name; return Ok(); }
public async Task<IHttpActionResult> PostTeacher(Teacher Teacher) { if (!ModelState.IsValid) { return BadRequest(ModelState); } _context.Teachers.Add(Teacher); return CreatedAtRoute("DefaultApi", new { id = Teacher.Id }, Teacher); }
public ActionResult Create(Teacher teacher) { try { teacher.Files = new List<ResourceFile>(); Academy.Current.AddOrUpdate(teacher); var body = MVCUtils.GetRazorViewAsString(teacher, "~/Views/Shared/Templates/tpl_teacher_create.cshtml"); Constants.mailer.SendMail(Constants.mailer.USER, teacher.Email, Constants.Email_Fahm_e_Islam, Constants.Email_BCC, "Your Account Has Been Created.", body, Constants.App_Title + " Team"); return RedirectToAction("Index"); } catch { return View(); } }
public ActionResult Edit(Teacher teacher) { try { var teacherold = Academy.Current.GetTeacherById(teacher.Id); teacher.Files = teacherold.Files; Academy.Current.AddOrUpdate(teacher); return RedirectToAction("Index"); } catch { return View(); } }