public async Task <IActionResult> Edit(int id, SchoolingCreateViewModel vm) { if (id != vm.Schooling.Id) { return(NotFound()); } if (ModelState.IsValid) { _bll.Schooling.Update(vm.Schooling); await _bll.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } vm.MaterialSelectList = new SelectList(await _bll.Material.AllAsync(), nameof(Material.Id), nameof(Material.MaterialName), vm.Schooling.MaterialId); vm.LocationSelectList = new SelectList(await _bll.Location.AllAsync(), nameof(BLL.App.DTO.Location.Id), nameof(BLL.App.DTO.Location.Locations), vm.Schooling.LocationId); return(View(vm)); }
// GET: Schoolings/Create public async Task <IActionResult> Create() { var vm = new SchoolingCreateViewModel() { MaterialSelectList = new SelectList(await _bll.Material.AllAsync(), nameof(BLL.App.DTO.Material.Id), nameof(BLL.App.DTO.Material.MaterialName)), LocationSelectList = new SelectList(await _bll.Location.AllAsync(), nameof(BLL.App.DTO.Location.Id), nameof(BLL.App.DTO.Location.Locations)) }; return(View(vm)); }
// GET: Schoolings/Edit/5 public async Task <IActionResult> Edit(int?id) { if (id == null) { return(NotFound()); } var schooling = await _bll.Schooling.FindAsync(id.Value); if (schooling == null) { return(NotFound()); } var vm = new SchoolingCreateViewModel() { Schooling = schooling, MaterialSelectList = new SelectList(await _bll.Material.AllAsync(), nameof(Material.Id), nameof(Material.MaterialName), schooling.MaterialId), LocationSelectList = new SelectList(await _bll.Location.AllAsync(), nameof(BLL.App.DTO.Location.Id), nameof(BLL.App.DTO.Location.Locations), schooling.LocationId) }; return(View(vm)); }