Esempio n. 1
0
        public IActionResult Post(Guid rosterId, [FromBody] Roster item)
        {
            if (item == null || item.Id != rosterId)
            {
                return(BadRequest());
            }
            var serverRoster = ServerRoster.FromRoster(item);

            _context.Rosters.Add(serverRoster);
            _context.SaveChanges();
            return(CreatedAtRoute(new { id = item.Id }, serverRoster));
        }
Esempio n. 2
0
        public IActionResult Put(Guid rosterId, [FromBody] Roster item)
        {
            if (item == null || item.Id != rosterId)
            {
                return(BadRequest());
            }
            var existing = _context.Rosters.Find(rosterId);

            if (existing == null)
            {
                return(NotFound());
            }
            var serverRoster = ServerRoster.FromRoster(item);

            _context.Entry(existing).CurrentValues.SetValues(serverRoster);
            _context.SaveChanges();
            return(new NoContentResult());
        }