예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("SatoId,KasviId,SatoPvm,Lämpötila,Määrä,Yksikkö,Lisätieto")] Satotiedot satotiedot)
        {
            if (id != satotiedot.SatoId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(satotiedot);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SatotiedotExists(satotiedot.SatoId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["KasviId"] = new SelectList(_context.Kasvit, "KasviId", "Nimi", satotiedot.KasviId);
            return(View(satotiedot));
        }
예제 #2
0
        public async Task <IActionResult> Create([Bind("SatoId,KasviId,SatoPvm,Lämpötila,Määrä,Yksikkö,Lisätieto")] Satotiedot satotiedot)
        {
            if (ModelState.IsValid)
            {
                _context.Add(satotiedot);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["KasviId"] = new SelectList(_context.Kasvit, "KasviId", "Nimi", satotiedot.KasviId);
            return(View(satotiedot));
        }