// PUT: api/Pegawai/5 public HttpResponseMessage Put(int id, [FromBody] perizinan value) { try { if (ModelState.IsValid) { using (var db = new OcphDbContext()) { var isUpdate = db.Perizinan.Update(O => new { O.Catatan, O.Jenis, O.Mulai, O.PegawaiId, O.Selesai }, value, O => O.Id == value.Id); if (isUpdate) { return(Request.CreateResponse(HttpStatusCode.OK, value)); } else { throw new SystemException("Data tidak tersimpan"); } } } else { throw new SystemException("Data Tidak Valid"); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.NotModified, ex.Message)); } }
// POST: api/Pegawai public HttpResponseMessage Post([FromBody] perizinan value) { try { if (ModelState.IsValid) { using (var db = new OcphDbContext()) { value.Id = db.Perizinan.InsertAndGetLastID(value); if (value.Id > 0) { return(Request.CreateResponse(HttpStatusCode.OK, value)); } else { throw new SystemException("Data tidak tersimpan"); } } } else { throw new SystemException("Data Tidak Valid"); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.NotModified, ex.Message)); } }
public AddperizinanViewModel(perizinan selectedItem) { LoadAsync(); this.Pegawai = selectedItem.Pegawai; this.Id = selectedItem.Id; this.Catatan = selectedItem.Catatan; this.Jenis = selectedItem.Jenis; this.Mulai = selectedItem.Mulai; this.PegawaiId = selectedItem.PegawaiId; this.Selesai = selectedItem.Selesai; this.SelectedItem = selectedItem; }
private void SaveCommandAction(object obj) { var item = new perizinan { Catatan = Catatan, Id = Id, Jenis = Jenis, Mulai = Mulai, PegawaiId = PegawaiId, Selesai = Selesai }; if (item.Id <= 0) { MainVM.PerizinanCollection.Add(item); } else { var res = MainVM.PerizinanCollection.Updated(item); if (res != null) { SelectedItem.Catatan = item.Catatan; SelectedItem.Jenis = item.Jenis; SelectedItem.Mulai = item.Mulai; SelectedItem.Selesai = item.Selesai; } } }
private void Data_OnChangeSource(perizinan obj) { MainCollection.SourceView.Refresh(); }
private void PerizinanCollection_OnChangeSource(perizinan obj) { WindowClose(); }