Esempio n. 1
0
        public async Task <IActionResult> Edit(Guid id, [Bind("Id,Datum,Kolicina")] Voda voda)
        {
            if (id != voda.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(voda);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!VodaExists(voda.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index), new { datumString = DajDatumZaParametra(voda.Datum) }));
            }
            return(RedirectToAction(nameof(Index), new { datumString = DajDatumZaParametra(DateTime.UtcNow.AddHours(2)) }));
        }
Esempio n. 2
0
        public async Task <IActionResult> Create([Bind("Id,Datum,Kolicina")] Voda voda)
        {
            if (ModelState.IsValid)
            {
                voda.Id       = Guid.NewGuid();
                voda.Korisnik = await _userManager.GetUserAsync(User);

                _context.Add(voda);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index), new { datumString = DajDatumZaParametra(voda.Datum) }));
            }
            return(RedirectToAction(nameof(Index), new { datumString = DajDatumZaParametra(DateTime.UtcNow.AddHours(2)) }));
        }