Esempio n. 1
0
        public async Task <ActionResult <API.Models.Type> > PostType(API.Models.Type @type)
        {
            _context.Types.Add(@type);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetType", new { id = @type.Id }, @type));
        }
Esempio n. 2
0
        public async Task <IActionResult> PutType(Guid id, API.Models.Type @type)
        {
            if (id != @type.Id)
            {
                return(BadRequest());
            }

            _context.Entry(@type).State = EntityState.Modified;

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

            return(NoContent());
        }