示例#1
0
        public RequestStatus GetRoom(ref Room room)
        {
            if (room == null)
            {
                return RequestStatus.InvalidInput;
            }

            room = Room.GetRoomByID(room.ID);

            return room != null ? RequestStatus.Success : RequestStatus.InvalidInput;
        }
示例#2
0
        public RequestStatus AddRoom(string token, ref Room newRoom)
        {
            if (string.IsNullOrWhiteSpace(token) || newRoom == null)
            {
                return RequestStatus.InvalidInput;
            }

            var p = Person.GetByToken(token);
            if (!p.IsAdmin())
            {
                return RequestStatus.AccessDenied;
            }

            newRoom = Room.AddRoom(newRoom);
            return newRoom != null ? RequestStatus.Success : RequestStatus.InvalidInput;
        }
示例#3
0
        public RequestStatus AddInventoryItemToRoom(string token, int inventoryId, ref Room updatedRoom)
        {
            if (string.IsNullOrWhiteSpace(token) || updatedRoom == null)
            {
                return RequestStatus.InvalidInput;
            }

            var p = Person.GetByToken(token);
            if (!p.IsAdmin())
            {
                return RequestStatus.AccessDenied;
            }

            updatedRoom = Room.GetRoomByID(updatedRoom.ID);
            return updatedRoom != null ? updatedRoom.AddInventory(inventoryId) : RequestStatus.InvalidInput;
        }
示例#4
0
文件: Room.cs 项目: esfdk/itubs
        public static Room AddRoom(Room newRoom)
        {
            if (newRoom.MaxParticipants > 0 && newRoom.Name.Length > 1)
            {
                BookITContext.Db.Rooms.Add(new Room { MaxParticipants = newRoom.MaxParticipants, Name = newRoom.Name });
                BookITContext.Db.SaveChanges();
            }
            else
            {
                return null;
            }

            return
                All.FirstOrDefault(
                    r =>
                    r.MaxParticipants == newRoom.MaxParticipants && r.Name.Equals(newRoom.Name) && r.Bookings.Count == 0
                    && r.Inventories.Count == 0);
        }
示例#5
0
        public RequestStatus EditRoom(string token, ref Room editedRoom)
        {
            if (string.IsNullOrWhiteSpace(token) || editedRoom == null)
            {
                return RequestStatus.InvalidInput;
            }

            var p = Person.GetByToken(token);
            if (!p.IsAdmin())
            {
                return RequestStatus.AccessDenied;
            }

            var room = Room.GetRoomByID(editedRoom.ID);
            if (room == null)
            {
                return RequestStatus.InvalidInput;
            }

            var rs = room.Edit(editedRoom);
            editedRoom = room;
            return rs;
        }
示例#6
0
        public RequestStatus RemoveRoom(string token, Room room)
        {
            if (string.IsNullOrWhiteSpace(token) || room == null)
            {
                return RequestStatus.InvalidInput;
            }

            var p = Person.GetByToken(token);
            if (!p.IsAdmin())
            {
                return RequestStatus.AccessDenied;
            }

            room = Room.GetRoomByID(room.ID);
            if (room == null)
            {
                return RequestStatus.InvalidInput;
            }

            room.Remove();
            return RequestStatus.Success;
        }
示例#7
0
文件: Room.cs 项目: esfdk/itubs
        public RequestStatus Edit(Room updatedRoom)
        {
            if (updatedRoom == null)
            {
                return RequestStatus.InvalidInput;
            }

            this.MaxParticipants = updatedRoom.MaxParticipants >= 0 ? updatedRoom.MaxParticipants : this.MaxParticipants;
            this.Name = !string.IsNullOrWhiteSpace(updatedRoom.Name) ? updatedRoom.Name : this.Name;

            BookITContext.Db.SaveChanges();

            return RequestStatus.Success;
        }