public IActionResult CreateMinorModel(InfoModel infoModel) { InfoModelViewModel viewModel = new InfoModelViewModel { InfoModel = infoModel }; return(View(viewModel)); }
public IActionResult CreateInfo(int id) { var courseDes = new InfoModelViewModel { CourseId = id }; return(View(courseDes)); }
public async Task <IActionResult> CreateMinorModel(InfoModelViewModel viewModel, int?id) { //TA DANDO ERRO PORQUE NÃO DA PRA CRIAR OS PAIS DE UMA MODELO QUE AINDA NÃO EXISTE NO BANCO DE DADOS. InfoModel model = viewModel.InfoModel; model.Parents = viewModel.Parents; await _modelsService.InsertAsync(model); return(RedirectToAction(nameof(Index))); }
// GET: InfoModels/Details/5 public async Task <IActionResult> Details(int?id) { if (id == null) { return(NotFound()); } InfoModel infoModel = await _modelsService.FindByIdAsync(id.Value); Parents parents = await _modelsService.FindParentsByIdAsync(infoModel.Id); if (infoModel == null) { return(NotFound()); } InfoModelViewModel viewModel = new InfoModelViewModel { InfoModel = infoModel, Parents = parents }; return(View(viewModel)); }
public async Task <IActionResult> CreateInfo(InfoModelViewModel model, int id) { if (ModelState.IsValid) { var course = _context.Courses.FirstOrDefault(x => x.Id == id); var cd = new InfoModel { Title = model.Title, Details = model.Details, dateTime = model.dateTime, Course = course }; _context.Add(cd); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(PostIndex))); } return(View(model)); }