Exemplo n.º 1
0
        // public async Task<EntityEntry<Faq>> AddAnFaq(FaqPostDto entity)
        public async Task <int> AddAnFaq(FaqPostDto newFaq)
        {
            var EntityFaq = new Faq();

            EntityFaq.FaqQuestion = newFaq.FaqQuestion;
            EntityFaq.FaqAnswer   = newFaq.FaqAnswer;
            await _context.FaqItems.AddAsync(EntityFaq);

            var numberInserted = _context.SaveChanges();

            return(numberInserted);
        }
Exemplo n.º 2
0
        public async Task <ActionResult> AddAnFaq(FaqPostDto faq)
        {
            if (!ModelState.IsValid)
            {
                _logger.LogError("In cfaq controller,  model not correct");
                return(BadRequest(ModelState));
            }
            var num = await _faqRepo.AddAnFaq(faq);

            if (num < 1)
            {
                _logger.LogError("In cfaq controller,  failed");
                return(BadRequest("The FAQ was not added."));
            }
            var confirm = _conf.ConfirmResponse(true, "An FAQ Item has been added successfully.");

            return(Ok(confirm));
        }