コード例 #1
0
 //
 // 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);
 }
コード例 #2
0
        // 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();
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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();
            }
        }
コード例 #5
0
        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();
            }
        }