Пример #1
0
        public ActionResult <Room> Post([FromBody] Room room)
        {
            var existing = db.Load(room.Name);

            if (existing != null)
            {
                return(BadRequest("exists"));
            }
            room.Owner = "TBD";
            db.Save(room.Name, room);
            return(room);
        }
Пример #2
0
        public void CreateRoom(string name, string owner)
        {
            var existing = _roomDatabase.Load(name);

            if (existing != null)
            {
                throw new Exception("room already exists");
            }
            _roomDatabase.Save(name, new Room()
            {
                Name = name, Owner = owner
            });
        }