Ejemplo n.º 1
0
        public async Task <IActionResult> PutAction([FromRoute] int id, [FromBody] DataAccess.Action action)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(NoContent());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> PostAction([FromBody] DataAccess.Action action)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Actions.Add(action);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetAction", new { id = action.Id }, action));
        }