Ejemplo n.º 1
0
 public IActionResult Edit(Mahasiswa mhs)
 {
     try{
         _mhs.Update(mhs);
         ViewData["pesan"] =
             "<span class='alert alert-success'> Data Mahasiswa Sudah Diubah</span>";
         return(View("Details", mhs));
     }catch (Exception ex)
     {
         return(Content($"Error: {ex.Message}"));
     }
 }
        public IActionResult Edit(MahasiswaViewModel data)
        {
            var nim_sub       = data.mhs.Nim;
            var angakatan_sub = nim_sub.Substring(2, 2);
            var angkatan      = "20" + angakatan_sub;

            data.mhs.Angkatan = angkatan;
            try
            {
                _mhs.Update(data);
                TempData["pesan"] = Helpers.Message.GetPesan("success", "Data mahasiswa berhasil diubah");
                return(RedirectToAction("Index"));
            }
            catch (Exception x) {
                TempData["pesan"] = Helpers.Message.GetPesan("danger", x.Message);
                return(RedirectToAction("Index"));
            }
        }