public ActionResult Edit(int id) { ViewBag.SelectedClass = from mt in _classService.GetClasses() select new SelectListItem { Value = mt.ClassId.ToString(), Text = mt.Name }; var projection = _chapterService.GetChapterById(id); if (projection == null) { _logger.Warn(string.Format("Chapter does not Exists {0}.", id)); Warning("Chapter does not Exists."); return(RedirectToAction("Index")); } ViewBag.ClassId = projection.ClassId; ViewBag.SubjectId = projection.SubjectId; var viewModel = AutoMapper.Mapper.Map <ChapterProjection, ChapterViewModel>(projection); return(View(viewModel)); }
public IActionResult Get(int id) { return(Ok(service.GetChapterById(id))); }