예제 #1
0
        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));
        }
예제 #2
0
        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();
        }
예제 #3
0
        public async Task <IHttpActionResult> GetNakup(int id)
        {
            Nakup nakup = await db.Nakups.FindAsync(id);

            if (nakup == null)
            {
                return(NotFound());
            }

            return(Ok(nakup));
        }
예제 #4
0
        //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);
        }
예제 #5
0
        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));
        }
예제 #6
0
        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
            };
        }
예제 #7
0
        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));
        }
예제 #8
0
        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();
            };
        }
예제 #9
0
 public void editNakup(Nakup nakup, int index)
 {
     NakupList[index] = nakup;
     ulozNakupList();
 }
예제 #10
0
 public void pridajNakup(Nakup nakup)
 {
     NakupList.Add(nakup);
     ulozNakupList();
 }