示例#1
0
        public async Task <IActionResult> PutShirtDetail([FromRoute] int id, [FromBody] ShirtDetail shirtDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != shirtDetail.ID)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
示例#2
0
        public async Task <IActionResult> PostShirtDetail([FromBody] ShirtDetail shirtDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.ShirtDetails.Add(shirtDetail);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetShirtDetail", new { id = shirtDetail.ID }, shirtDetail));
        }