Esempio n. 1
0
        public async Task <IActionResult> PutComment(long id)
        {
            var comment = await _context.comments.FindAsync(id);

            if (comment == null)
            {
                return(NotFound());
            }

            comment.approved = true;

            await _context.SaveChangesAsync();

            return(NoContent());
        }
Esempio n. 2
0
        public async Task <long> NewThread(NewThreadDTO newThread)
        {
            var _threads = await _context.threads.ToListAsync();

            foreach (Thread eachThread in _threads)
            {
                if (eachThread.hostname == newThread.hostname && eachThread.path == newThread.path)
                {
                    return(eachThread.id);
                }
            }

            var thread = new Thread {
                hostname = newThread.hostname,
                path     = newThread.path,
                ownerId  = getOwner(newThread.hostname)
            };

            _context.threads.Add(thread);
            await _context.SaveChangesAsync();

            return(ItemToDTO(thread).id);
        }