public async Task <IActionResult> Edit(int id, [Bind("ID,PicDesc,Remark,IsActive,DateCreate,UserCreate,DateUpdate,UserUpdate")] PicCodeModel picCodeModel) { if (id != picCodeModel.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(picCodeModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PicCodeModelExists(picCodeModel.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(picCodeModel)); }
public async Task <IActionResult> Create([Bind("PicDesc,Remark")] CreatePicCodeVM cpm) { if (ModelState.IsValid) { PicCodeModel Picm = new PicCodeModel(); Picm.PicDesc = cpm.PicDesc; Picm.Remark = cpm.Remark; _context.Add(Picm); try { await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } catch (Exception ex) { flashMessage.Danger(ex.Message); } } return(View(cpm)); }