public async Task <IActionResult> PutRoom([FromRoute] int id, [FromBody] Room room) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != room.RoomId) { return(BadRequest()); } Utilities.Log(_context, HttpContext, $"Update room {room.RoomId} ({room.Location} {room.RoomName})", 2, true); _context.Entry(room).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RoomExists(id)) { return(NotFound()); } else { throw; } } UpdateLayoutWebSocket(new [] { room }); return(NoContent()); }
public async Task <IActionResult> PutRoomAllocation([FromRoute] int id, [FromBody] RoomAllocation roomAllocation) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != roomAllocation.Sno) { return(BadRequest()); } _context.Entry(roomAllocation).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RoomAllocationExists(id)) { return(NotFound()); } else { throw; } } RoomAllocation ra = _context.RoomAllocation.Include(m => m.Room) .Where(m => m.Sno == roomAllocation.Sno).FirstOrDefault(); if (ra != null) { UpdateLayoutWebSocket(new Room[] { ra.Room }); } return(NoContent()); }