public async Task <ActionResult> Edit(int id) { var recruit = await _recruitsService.GetByIdAsync(id); if (recruit == null) { return(NotFound()); } _recruitsService.LoadSubItems(recruit); var model = new RecruitEditForm() { Recruit = recruit.MapViewModel(_mapper) }; if (recruit.ParentId > 0) { var parent = await _recruitsService.GetByIdAsync(recruit.ParentId); if (parent != null) { model.Recruit.Parent = parent.MapViewModel(_mapper); } } else { var subjects = _subjectsService.FetchRootItems(); model.SubjectOptions = subjects.Select(item => new BaseOption <int>(item.Id, item.Title)).ToList(); } return(Ok(model)); }
public ActionResult Create() { var model = new RecruitEditForm(); var subjects = _subjectsService.FetchRootItems(); model.SubjectOptions = subjects.Select(item => new BaseOption <int>(item.Id, item.Title)).ToList(); return(Ok(model)); }