コード例 #1
0
        public async Task <IActionResult> PostUndertakenInitiatives([FromBody] UndertakenInitiatives undertakenInitiatives)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.UndertakenInitiatives.Add(undertakenInitiatives);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetUndertakenInitiatives", new { id = undertakenInitiatives.UndertakenInitiativeID }, undertakenInitiatives));
        }
コード例 #2
0
        public async Task <IActionResult> PutUndertakenInitiatives([FromRoute] Guid id, [FromBody] UndertakenInitiatives undertakenInitiatives)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != undertakenInitiatives.UndertakenInitiativeID)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }