Exemplo n.º 1
0
        public ActionResult SubjectList(SubjectMaster subjectMaster)
        {
            SubjectService add = new SubjectService();

            add.AddSubject(subjectMaster);
            return(RedirectToAction("AllSubjects"));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> OnPostAddSubject()
        {
            if (ModelState.IsValid)
            {
                AddSubject.UserId = int.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier));
                await _subjectService.AddSubject(AddSubject);

                return(LocalRedirect("/"));
            }
            return(Page());
        }
Exemplo n.º 3
0
        public ActionResult AddSubject(Subjects subjects)
        {
            try
            {
                // TODO: Add delete logic here
                SubjectService subjectService = new SubjectService();
                subjectService.AddSubject(subjects);

                return(RedirectToAction("SubjectPage"));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult Create(SubjectViewModel subject)
        {
            try
            {
                subjectService.AddSubject(subject);

                var subjects = subjectService.GetSubjects();
                return(Json(new ResponseData()
                {
                    Status = true,
                    Data = subjects
                }));
            }
            catch (Exception ex)
            {
                logger.Error($"新增課程失敗 SudjectId:{subject.SubjectId},Name:{subject.Name},Credit:{subject.Credit},Location:{subject.Location},teacherName:{subject.teacherName}");
                return(Json(new ResponseData()
                {
                    Status = false,
                    Message = ex.Message
                }));
            }
        }
Exemplo n.º 5
0
        public IActionResult Add(NewSubjectViewModel model)
        {
            var success = service.AddSubject(model.Name);

            return(Ok(success));
        }
Exemplo n.º 6
0
        public void AddSubjectByNullTest()
        {
            var result = subjectserv.AddSubject(null);

            Assert.AreEqual(result.ErrorMessage, "Subject not be null");
        }