Exemple #1
0
        public ActionResult Create(SubjectViewModel subject)
        {
            if (ModelState.IsValid)
            {
                var subjectDomain = Mapper.Map <SubjectViewModel, Subject>(subject);
                _subjectApp.Add(subjectDomain);

                return(RedirectToAction("Index"));
            }

            ViewBag.CourseId  = new SelectList(_courseApp.GetAll(), "Id", "Name", subject.CourseId);
            ViewBag.TeacherId = new SelectList(_teacherApp.GetAll(), "Id", "Name", subject.TeacherId);
            return(View(subject));
        }
Exemple #2
0
        public ResponseBase Add(Subject subject)
        {
            ResponseBase response = new ResponseBase();

            try
            {
                response.Success = _appService.Add(subject);
            }
            catch (LibraryException ex)
            {
                response.Message = ex.Message;
            }
            catch (Exception)
            {
                response.Message = "Internal server error";
            }

            return(response);
        }