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

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

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

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

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

            _context.CustomerFeeds.Add(customerFeedBack);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetCustomerFeedBack", new { id = customerFeedBack.ID }, customerFeedBack));
        }