Exemple #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Company,Message,DatePublished,Publish")] TestimonyModel testimonyModel)
        {
            if (id != testimonyModel.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(testimonyModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TestimonyModelExists(testimonyModel.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(testimonyModel));
        }
Exemple #2
0
        public async Task <IActionResult> Testimonials([Bind("Id,Name,Company,Message,DatePublished,Publish")] TestimonyModel testimonyModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(testimonyModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Thanks)));
            }
            return(View(testimonyModel));
        }