示例#1
0
        public ActionResult Delete(Jurusan model)
        {
            int idx = listJurusan.FindIndex(e => e.Id == model.Id);

            listJurusan.Remove(listJurusan[idx]);
            return(RedirectToAction("Index"));
        }
示例#2
0
        public ActionResult Edit(Jurusan model)
        {
            int idx = listJurusan.FindIndex(e => e.Id == model.Id);

            listJurusan[idx] = model;
            return(RedirectToAction("Index"));
        }
示例#3
0
 public TambahJurusanView(Jurusan selectedItem)
 {
     InitializeComponent();
     this.DataContext = new TambahJurusanModel(selectedItem)
     {
         WindowClose = this.Close
     };
 }
示例#4
0
        public ActionResult Create(Jurusan model)
        {
            int idx = listJurusan.Max(e => e.Id) + 1;

            model.Id = idx;
            listJurusan.Add(model);
            return(RedirectToAction("Index"));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Jurusan jurusan = db.Jurusans.Find(id);

            db.Jurusans.Remove(jurusan);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "JurusanID,Id_jurusan,Nama_Jurusan")] Jurusan jurusan)
 {
     if (ModelState.IsValid)
     {
         db.Entry(jurusan).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(jurusan));
 }
        public ActionResult Create([Bind(Include = "JurusanID,Id_jurusan,Nama_Jurusan")] Jurusan jurusan)
        {
            if (ModelState.IsValid)
            {
                db.Jurusans.Add(jurusan);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(jurusan));
        }
示例#8
0
 public TambahJurusanModel(Jurusan selectedItem)
 {
     MyTitle           = "Tambah Edit";
     this.selectedItem = selectedItem;
     Id            = selectedItem.Id;
     this.Kode     = selectedItem.Kode;
     this.Name     = selectedItem.Name;
     CancelCommand = new CommandHandler {
         CanExecuteAction = x => true, ExecuteAction = CancelAction
     };
     SaveCommand = new CommandHandler {
         CanExecuteAction = SaveValidate, ExecuteAction = SaveAction
     };
 }
        // GET: Jurusans/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Jurusan jurusan = db.Jurusans.Find(id);

            if (jurusan == null)
            {
                return(HttpNotFound());
            }
            return(View(jurusan));
        }
示例#10
0
 private void SaveAction(object obj)
 {
     try
     {
         var model = new Jurusan {
             Id = this.Id, Kode = this.Kode, Name = Name
         };
         using (var db = new DbContext())
         {
             if (selectedItem != null)
             {
                 if (db.Jurusan.Update(x => new { x.Kode, x.Name }, model, x => x.Id == model.Id))
                 {
                     Model = model;
                     MessageBox.Show("Jurusan Perhasil Diubah", "Info", MessageBoxButton.OK, MessageBoxImage.Information);
                 }
                 else
                 {
                     throw new SystemException("Data Tidak Tersimpan");
                 }
             }
             else
             {
                 model.Id = db.Jurusan.InsertAndGetLastID(model);
                 if (model.Id <= 0)
                 {
                     throw new SystemException("Data Tidak Tersimpan");
                 }
                 Model = model;
                 MessageBox.Show("Jurusan Perhasil Ditambahkan", "Info", MessageBoxButton.OK, MessageBoxImage.Information);
             }
             WindowClose();
         }
     }
     catch (Exception ex)
     {
         Crashes.TrackError(ex);
         MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
示例#11
0
        public ActionResult Delete(int Id)
        {
            Jurusan idx = listJurusan.Find(e => e.Id == Id);

            return(View(idx));
        }
示例#12
0
 private void CancelAction(object obj)
 {
     Model = null;
     WindowClose();
 }