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) } }; }
public async Task<InterviewViewModel> Create(AddInterviewViewModel viewModel) { var interview = _mappingEngine.Map<Interview>(viewModel); _interviews.Add(interview); await _unitOfWork.SaveChangesAsync(); return await _interviews .Include(a => a.CreatedBy).Include(a => a.ModifiedBy).AsNoTracking() .ProjectTo<InterviewViewModel>(_mappingEngine) .FirstOrDefaultAsync(a => a.Id == interview.Id); }
public async Task<InterviewViewModel> Create(AddInterviewViewModel viewModel) { var interview = _mappingEngine.Map<Interview>(viewModel); interview.CreatorId = _userManager.GetCurrentUserId(); if (viewModel.AttachmentScan.HasValue()) interview.Attachment = Convert.FromBase64String(viewModel.AttachmentScan); else if (viewModel.AttachmentFile.HasFile()) { interview.Attachment = viewModel.AttachmentFile.InputStream.ConvertToByteArrary(viewModel.AttachmentFile.ContentLength); } _interviews.Add(interview); await _unitOfWork.SaveChangesAsync(); return await _interviews.Include(a => a.Interviewer) .Include(a => a.Creator).Include(a => a.LasModifier).AsNoTracking() .ProjectTo<InterviewViewModel>(_mappingEngine) .FirstOrDefaultAsync(a => a.Id == interview.Id); }
public async Task FillAddViewModel(AddInterviewViewModel viewModel) { viewModel.Interviewers = await _appraiserService.GetAsSelectedListItem(null); }
public virtual async Task<ActionResult> Create(AddInterviewViewModel viewModel) { if (!_referentialTeacherService.CanManageTeacher(viewModel.TeacherId)) return HttpNotFound(); if (!ModelState.IsValid) { await _interviewService.FillAddViewModel(viewModel); 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) } }; }
public virtual ActionResult Create(Guid applicantId) { var viewModel = new AddInterviewViewModel {ApplicantId = applicantId}; return PartialView(MVC.Interview.Views._Create, viewModel); }