Esempio n. 1
0
        public IActionResult Post([FromBody] JsonPassThroughModel newForm)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var newEntity = newForm.ToEntity();

            _context.JsonPassThroughEntities.Add(newEntity);
            _context.SaveChanges();

            return(CreatedAtRoute(ROUTE_GetEntityById, new { id = newEntity.Id }, newEntity));
        }
Esempio n. 2
0
        public IActionResult Put(int id, [FromBody] JsonPassThroughModel updatedForm)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var found = GetEntityById(id);

            if (found == null)
            {
                return(NotFound());
            }

            updatedForm.UpdateEntity(ref found);
            _context.SaveChanges();

            return(NoContent());
        }