public IHttpActionResult CreateRoom(Room roomToCreate) { try { db.Rooms.Add ( roomToCreate ); db.SaveChanges ( ); } catch (Exception ex) { Console.WriteLine ( ex.Message ); } responseText = "Room: " + roomToCreate.RoomNo + " (Level: " + roomToCreate.FloorNo.ToString ( ) + ") Created"; return Ok ( responseText ); }
public IHttpActionResult UpdateRoom(Room roomToUpdate) { try { db.Rooms.Attach ( roomToUpdate ); db.Entry ( roomToUpdate ).State = EntityState.Modified; db.SaveChanges ( ); } catch (Exception ex) { Console.WriteLine ( ex.Message ); } responseText = "Room: " + roomToUpdate.RoomNo + " (Level: " + roomToUpdate.FloorNo.ToString ( ) + ") Created"; return Ok ( responseText ); }