public async Task <IActionResult> Edit(int id, [Bind("Id,brojNaKarticka,tipNaKarticka,paricnaSostojba,korisnickaSmetkaId")] Karticka karticka)
        {
            if (id != karticka.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(karticka);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!KartickaExists(karticka.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["korisnickaSmetkaId"] = new SelectList(_context.KorisnickaSmetka, "Id", "bankarskiBroj", karticka.korisnickaSmetkaId);
            return(View(karticka));
        }
Beispiel #2
0
        public async Task <IActionResult> PutKarticka([FromRoute] int id, [FromBody] Karticka karticka)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != karticka.Id)
            {
                return(BadRequest());
            }

            _context.Entry(karticka).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!KartickaExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> Create([Bind("Id,brojNaKarticka,tipNaKarticka,paricnaSostojba,korisnickaSmetkaId")] Karticka karticka)
        {
            if (ModelState.IsValid)
            {
                _context.Add(karticka);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["korisnickaSmetkaId"] = new SelectList(_context.KorisnickaSmetka, "Id", "bankarskiBroj", karticka.korisnickaSmetkaId);
            return(View(karticka));
        }
Beispiel #4
0
        public async Task <IActionResult> PostKarticka([FromBody] Karticka karticka)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Karticka.Add(karticka);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetKarticka", new { id = karticka.Id }, karticka));
        }