コード例 #1
0
        public async Task <IActionResult> PutComolaints([FromRoute] int id, [FromBody] Comolaints comolaints)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != comolaints.Id)
            {
                return(BadRequest());
            }

            _context.Entry(comolaints).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ComolaintsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #2
0
        public async Task <IActionResult> PostComolaints([FromBody] Comolaints comolaints)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Comolaints.Add(comolaints);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetComolaints", new { id = comolaints.Id }, comolaints));
        }