// PUT: /Knowledges/5
        /// <summary>
        /// Support for updating Knowledges
        /// </summary>
        public async Task <IActionResult> Put([FromODataUri] int key, [FromBody] Knowledge update)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (key != update.Id)
            {
                return(BadRequest());
            }

            _context.Entry(update).State = EntityState.Modified;
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!_context.Knowledge.Any(p => p.Id == key))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Updated(update));
        }
Beispiel #2
0
        public async Task <IActionResult> Put([FromODataUri] string userid, [FromBody] Quizuser update)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (String.CompareOrdinal(userid, update.Userid) != 0)
            {
                return(BadRequest());
            }

            _context.Entry(update).State = EntityState.Modified;
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!_context.Quizuser.Any(p => String.CompareOrdinal(p.Userid, userid) == 0))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Updated(update));
        }
        public async Task <IActionResult> Post(Permuser puser)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Permuser.Add(puser);
            await _context.SaveChangesAsync();

            return(Created(puser));
        }
        public async Task <IActionResult> Post([FromBody] Qbklink link)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Qbklink.Add(link);
            await _context.SaveChangesAsync();

            return(Created(link));
        }