Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,DateAdded,Question,Answer")] QnAPair qnAPair)
        {
            if (id != qnAPair.Id)
            {
                return(NotFound());
            }

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

                return(RedirectToAction(nameof(Index)));
            }
            return(View(qnAPair));
        }
Exemplo n.º 3
0
        public async Task <IHttpActionResult> Post(QnAPair qnAPair)
        {
            await _kbService.UpdateAsync(qnAPair.question, qnAPair.answer);

            return(Ok());
        }