private void btnAracKirala_Click(object sender, EventArgs e) { try { bool success; using (var kiralikBusiness = new KiralikBusiness()) { success = kiralikBusiness.AracKirala(new Kiralik() { kiralananAracID = int.Parse(txtKiraAracID.Text), kiraTarihi = DateTime.Parse(dtpKiraTarihi.Text), verilisKM = int.Parse(txtVerilisKM.Text), kiraBitisKM = int.Parse(txtKiraBitisKM.Text), kiraAlinanUcret = int.Parse(txtAlinanUcret.Text), kiralayanKulID = int.Parse(txtKullID.Text) }); } var message = success ? "Araç Kiralama Başarılı" : "Hata oluştu"; MessageBox.Show(message); } catch (Exception ex) { MessageBox.Show("Error happened: " + ex.Message); } kiralananListele(); inputTemizle(); }
// POST api/<controller> public IHttpActionResult Post([FromBody] Kiralik kiralik) { var content = new ResponseContent <Kiralik>(null); if (kiralik != null) { using (var kiralikBusiness = new KiralikBusiness()) { content.Result = kiralikBusiness.AracKirala(kiralik) ? "1" : "0"; return(new StandartResult <Kiralik>(content, Request)); } } content.Result = "0"; return(new StandartResult <Kiralik>(content, Request)); }