private void CollectMahassiswa(ProgramStudi value)
        {
            if (value == null)
            {
                this.DataSource.Clear();
            }
            else
            {
                using (var db = new DbContext())
                {
                    int number = 1;
                    DataSource.Clear();
                    foreach (var item in db.Mahasiswa.Where(x => x.IdProgdi == value.Id).ToList())
                    {
                        item.Nomor          = number;
                        item.Jurusan        = db.Jurusan.Where(x => x.Id == item.IdJurusan).FirstOrDefault();
                        item.SukuModel      = DataHelpers.DataSuku.Where(x => x.Nilai == item.Suku).FirstOrDefault();
                        item.GelombangModel = DataHelpers.DataGelombang.Where(x => x.Nilai == item.Gelombang).FirstOrDefault();
                        DataSource.Add(item);
                        number++;
                    }
                }
            }

            Source.Refresh();
        }
 public TambahMahasiswaView(ProgramStudi selectedProgdi)
 {
     InitializeComponent();
     this.DataContext = new TambahMahasiswaViewModel(selectedProgdi)
     {
         WindowClose = this.Close
     };
 }
Ejemplo n.º 3
0
        public async Task <IActionResult> Put(int id, ProgramStudi model)
        {
            try
            {
                var response = await _prodiService.Put(id, model);

                return(Ok(response));
            }
            catch (System.Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
 public TambahProgdiViewModel(ProgramStudi selectedItem)
 {
     MyTitle           = "Edit Program Studi";
     this.selectedItem = selectedItem;
     Id            = selectedItem.Id;
     this.Jenjang  = selectedItem.Jenjang;
     this.Kode     = selectedItem.Kode;
     this.Name     = selectedItem.Name;
     CancelCommand = new CommandHandler {
         CanExecuteAction = x => true, ExecuteAction = CancelAction
     };
     SaveCommand = new CommandHandler {
         CanExecuteAction = SaveValidate, ExecuteAction = SaveAction
     };
 }
Ejemplo n.º 5
0
 internal void EditProgdi(IItem selectedItem)
 {
     try
     {
         using (var db = new DbContext())
         {
             var model = new ProgramStudi {
                 Id = selectedItem.Id, Kode = selectedItem.Kode, Name = selectedItem.Name
             };
             var updated = db.Progdi.Update(x => new { x.Kode, x.Name, x.Jenjang }, model, x => x.Id == selectedItem.Id);
             if (!updated)
             {
                 throw new SystemException("Data Tidak Berhasil Diubah");
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 private void SaveAction(object obj)
 {
     try
     {
         var model = new ProgramStudi {
             Id = Id, ParentId = this.ParentId, Jenjang = this.Jenjang, Kode = this.Kode, Name = this.Name
         };
         using (var db = new DbContext())
         {
             if (selectedItem != null)
             {
                 if (db.Progdi.Update(x => new { x.Jenjang, x.Kode, x.Name }, model, x => x.Id == model.Id))
                 {
                     Model = model;
                     MessageBox.Show("Program Studi Perhasil Diubah", "Info", MessageBoxButton.OK, MessageBoxImage.Information);
                 }
                 else
                 {
                     throw new SystemException("Data Tidak Tersimpan");
                 }
             }
             else
             {
                 model.Id = db.Progdi.InsertAndGetLastID(model);
                 if (model.Id <= 0)
                 {
                     throw new SystemException("Data Tidak Tersimpan");
                 }
                 Model = model;
                 MessageBox.Show("Program Studi Perhasil Ditambahkan", "Info", MessageBoxButton.OK, MessageBoxImage.Information);
             }
             WindowClose();
         }
     }
     catch (Exception ex)
     {
         Crashes.TrackError(ex);
         MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
 private void CancelAction(object obj)
 {
     Model = null;
     WindowClose();
 }
 public TambahMahasiswaViewModel(ProgramStudi selectedProgdi)
 {
     MyTitle       = "Tambah Mahasiswa";
     this.IdProgdi = selectedProgdi.Id;
     Load();
 }