public async Task <IHttpActionResult> PutNakup(int id, Nakup nakup) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != nakup.Id) { return(BadRequest()); } db.Entry(nakup).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!NakupExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
private void ulozit() { string obchodNakupu = txtObchod.Text; double vydajNakupu = double.Parse(txtVydaj.Text, CultureInfo.InvariantCulture); string kategoriaNakupu = txtKategoria.Text; Nakup nakup = new Nakup(obchodNakupu, vydajNakupu, den, mesiac, rok, kategoriaNakupu); NakupServis.getInstance().editNakup(nakup, idNakup); Finish(); }
public async Task <IHttpActionResult> GetNakup(int id) { Nakup nakup = await db.Nakups.FindAsync(id); if (nakup == null) { return(NotFound()); } return(Ok(nakup)); }
//ulozenie do objektu public void ulozit() { string obchodNakupu = txtObchod.Text; double vydajNakupu = double.Parse(txtVydaj.Text, CultureInfo.InvariantCulture); string kategoriaNakupu = txtKategoria.Text; Nakup nakup = new Nakup(obchodNakupu, vydajNakupu, den, mesiac, rok, kategoriaNakupu); nakupPrehladJson = JsonConvert.SerializeObject(nakup); NakupServis.getInstance().pridajNakup(nakup); }
public async Task <IHttpActionResult> PostNakup(Nakup nakup) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Nakups.Add(nakup); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = nakup.Id }, nakup)); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.nakup_activity_detail_layout); SupportActionBar.SetDisplayShowHomeEnabled(true); SupportActionBar.SetDisplayHomeAsUpEnabled(true); btnDatum = FindViewById <Button>(Resource.Id.btnDatumDetail); btnSave = FindViewById <Button>(Resource.Id.btnSaveDetail); btnDelete = FindViewById <Button>(Resource.Id.btnDeleteDetail); txtObchod = FindViewById <EditText>(Resource.Id.txtObchodDetail); txtVydaj = FindViewById <EditText>(Resource.Id.txtCenaDetail); txtDatum = FindViewById <TextView>(Resource.Id.txtDatumDetail); txtKategoria = FindViewById <EditText>(Resource.Id.txtKatDetail); btnSave.Click += delegate { ulozit(); }; idNakup = Intent.GetIntExtra(ID_NAKUP, -1); if (idNakup >= 0) { IList <Nakup> nakupList = NakupServis.getInstance().GetNakupList(); Nakup nakup = nakupList[idNakup]; txtObchod.Text = nakup.obchodNakup; txtVydaj.Text = nakup.vydajNakup.ToString(); txtKategoria.Text = nakup.kategoria; txtDatum.Text = nakup.den + "." + nakup.mesiac + "." + nakup.rok; den = nakup.den; mesiac = nakup.mesiac; rok = nakup.rok; } btnDelete.Click += delegate { vymazat(); }; //button cez ktorý otvoríme dialog na dátum btnDatum.Click += delegate { #pragma warning disable CS0618 // Type or member is obsolete ShowDialog(DATE_DIALOG); #pragma warning restore CS0618 // Type or member is obsolete }; }
public async Task <IHttpActionResult> DeleteNakup(int id) { Nakup nakup = await db.Nakups.FindAsync(id); if (nakup == null) { return(NotFound()); } db.Nakups.Remove(nakup); await db.SaveChangesAsync(); return(Ok(nakup)); }
protected override void OnCreate(Bundle SavedInstanceState) { base.OnCreate(SavedInstanceState); SetContentView(Resource.Layout.nakup_activity_prehlad_layout); txtObchod = FindViewById <TextView>(Resource.Id.txtObchodPrehlad); txtCena = FindViewById <TextView>(Resource.Id.txtCenaPrehlad); txtDatum = FindViewById <TextView>(Resource.Id.txtDatumPrehlad); txtKategoria = FindViewById <TextView>(Resource.Id.txtKatPrehlad); btnGrafy = FindViewById <Button>(Resource.Id.btnGrafy); btnNakupList = FindViewById <Button>(Resource.Id.btnNakupList); btnNovyNakup = FindViewById <Button>(Resource.Id.btnNovyNakup); //nakupPrehladJson = Intent.GetStringExtra("Nakup"); Nakup nakup = JsonConvert.DeserializeObject <Nakup>(Intent.GetStringExtra("Nakup")); txtObchod.Text = nakup.obchodNakup; txtCena.Text = nakup.vydajNakup.ToString(); txtKategoria.Text = nakup.kategoria; txtDatum.Text = nakup.den + "." + nakup.mesiac + "." + nakup.rok; btnGrafy.Click += delegate { MainActivity.startActivity(this); Finish(); }; btnNakupList.Click += delegate { NakupListActivity.StartActivity(this); Finish(); }; btnNovyNakup.Click += delegate { NakupActivity.startActivity(this); Finish(); }; }
public void editNakup(Nakup nakup, int index) { NakupList[index] = nakup; ulozNakupList(); }
public void pridajNakup(Nakup nakup) { NakupList.Add(nakup); ulozNakupList(); }