public IActionResult Edit(int id, [Bind("Id,EntryId,PlatformId,Description")] EntryPlatformListViewModel vwModel) { if (id != vwModel.Id) { return(NotFound()); } if (ModelState.IsValid) { try { var dbModel = _mapper.Map <EntryPlatformModel>(vwModel); _entryPlatformRepository.Update(dbModel); ViewData["message"] = "Entry updated successfully."; } catch (Exception ex) { // TODO ~ log something? return(NotFound()); } } SetSelectList(); return(View(vwModel)); }
// GET: EntryPlatform/Create/5 public IActionResult Create(int id) { if (id == 0) { return(NotFound()); } var vwModel = new EntryPlatformListViewModel() { EntryId = id }; SetSelectList(); return(View(vwModel)); }
public IActionResult Create([Bind("EntryId,PlatformId,Description")] EntryPlatformListViewModel vwModel) { if (ModelState.IsValid) { var dbModel = _mapper.Map <EntryPlatformModel>(vwModel); _entryPlatformRepository.Insert(dbModel); ViewData["message"] = "PLatform entry added successfully."; ModelState.SetModelValue("Description", new ValueProviderResult("")); ModelState.SetModelValue("PlatformId", new ValueProviderResult("")); var vwModel2 = new EntryPlatformListViewModel() { EntryId = vwModel.EntryId }; SetSelectList(); return(View(vwModel2)); } return(View(vwModel)); }