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

            if (id != nmWorkoutActivity.NmWaId)
            {
                return(BadRequest());
            }

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

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

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

            _context.NmWorkoutActivity.Add(nmWorkoutActivity);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetNmWorkoutActivity", new { id = nmWorkoutActivity.NmWaId }, nmWorkoutActivity));
        }