예제 #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;
        }