Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Rate,Comment")] PetRate petRate)
        {
            if (id != petRate.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(petRate);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PetRateExists(petRate.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(petRate));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("Id,Rate,Comment")] PetRate petRate)
        {
            if (ModelState.IsValid)
            {
                _context.Add(petRate);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(petRate));
        }