public async Task <ActionResult> Create(IFormCollection collection) { try { // TODO: Add insert logic here interview = new Interview { Report = "", Start = DateTime.Now, Finish = DateTime.Now, LibraryId = 1, CandidateId = Convert.ToInt16(collection["CandidateId"]), Candidate = new Candidate() }; await _interviewService.Create(interview); Interview createdInterview = await _interviewService.GetbyId(interview.Id); return(RedirectToAction("Create", "Test", new { candidateId = createdInterview.Id })); } catch { return(View()); } }
public IActionResult Register([FromBody] InterviewModel interviewModel) { // map dto to entity var interview = _iMapper.Map <Interview>(interviewModel); try { // save var result = _iInterviewService.Create(interview, interview.PostId, interview.ResumeId); var count = 1; if (result != null) { return(Output(new DeleteOrUpdateResponse { id = result.InterviewId, }, count)); } throw new Exception("创建失败!"); } catch (AppException ex) { // return error message if there was an exception return(BadRequest(new { message = ex.Message })); } }
public virtual async Task <ActionResult> Create(AddInterviewViewModel viewModel) { if (!ModelState.IsValid) { return(new JsonNetResult { Data = new { success = false, View = this.RenderPartialViewToString(MVC.Interview.Views._Create, viewModel) } }); } viewModel.Brief = viewModel.Brief.ToSafeHtml(); viewModel.Body = viewModel.Body.ToSafeHtml(); var newInterview = await _interviewService.Create(viewModel); return(new JsonNetResult { Data = new { success = true, View = this.RenderPartialViewToString(MVC.Interview.Views._InterviewItem, newInterview) } }); }