Exemple #1
0
        public async Task <bool> EndreFAQ([FromBody] FAQ enFAQ)
        {
            try
            {
                FAQ faq = _db.FAQs.Find(enFAQ.id);

                _log.LogInformation("Endret faq: " + faq.rating + " til: " + enFAQ.rating);

                if (faq != null)
                {
                    faq.rating = enFAQ.rating;
                }
                else
                {
                    return(false);
                }

                await _db.SaveChangesAsync();

                return(true);
            }
            catch (Exception exp)
            {
                _log.LogInformation("EndreFAQ feilet: " + exp.Message);
                return(false);
            }
        }
Exemple #2
0
        public async Task <bool> EndreLikesFAQ([FromBody] FAQDTO endreFAQ)
        {
            try
            {
                FAQ FAQ = await _db.faqs
                          .FirstOrDefaultAsync(x => x.id == endreFAQ.id);

                _log.LogInformation("Endrer likes: " + FAQ.like + " til " + endreFAQ.likes + "\n"
                                    + "Endrer dislikes: " + FAQ.dislike + " til " + endreFAQ.dislikes);

                if (FAQ != null)
                {
                    FAQ.like    = endreFAQ.likes;
                    FAQ.dislike = endreFAQ.dislikes;
                }
                else
                {
                    return(false);
                }

                await _db.SaveChangesAsync();

                return(true);
            }
            catch (Exception exp)
            {
                _log.LogInformation("EndreLikes feilet: " + exp.Message);
                return(false);
            }
        }