Example #1
0
        public override bool AddToBag(Slot slot)
        {
            Slot adic = new Slot(slot.ItemID, slot.ItemAmount);

            if (adic != null && Slots.Count() < mobCarry)
            {
                Slots.Add(adic);
                return(true);
            }
            else
            {
                return(true);
            }
        }
Example #2
0
 public virtual void DropContent()
 {
     lock (_containerLock)
     {
         for (short i = 0; i < Slots.Count(); i++)
         {
             ItemInventory stack = Slots[i];
             if (stack != null && !ItemHelper.IsVoid(stack))
             {
                 World.Server.DropItem(World, Coords, stack);
                 this[i] = ItemHelper.Void;
             }
         }
         Save();
     }
 }
Example #3
0
        public EquipmentCarrier(IEnumerable <PersonSlotSubScheme> slots)
        {
            Slots = slots.ToArray();

            Equipments = new Equipment[Slots.Count()];
        }
            public void Add1Slot_SlotsCountIncrease1()
            {
                AddSlots(_sampleSlot1);

                Slots.Count().Should().Be(1);
            }
Example #5
0
        /// <summary>
        /// Creates a Slot with the given details within the database.
        /// </summary>
        /// <param name="roomName">Room ID</param>
        /// <param name="bookingDate">Date to create the slot</param>
        /// <param name="iD">Id of the booking member</param>
        /// <returns></returns>
        public Result CreateSlot(string roomName, DateTime bookingDate, string iD)
        {
            // Check room is exists.
            if (!Rooms.Contains(roomName))
            {
                return(new Result {
                    Success = false, ErrorMsg = "Room does not exist"
                });
            }

            if (Slots.Count(x => x.StartTime.Date == bookingDate.Date && x.RoomName == roomName) >= 2)
            {
                return(new Result {
                    Success = false, ErrorMsg = "A room can be booked for a maximum of 2 slots per day"
                });
            }

            // Check slot does not already exist.
            if (FindSlot(roomName, bookingDate) != null)
            {
                return(new Result {
                    Success = false, ErrorMsg = "Slot already exists"
                });
            }

            // Check id exists.
            if (!GetStaff().Any(x => x.Id == iD))
            {
                return(new Result {
                    Success = false, ErrorMsg = "Staff member does not exist"
                });
            }

            if (Slots.Count(x => x.StartTime.Date == bookingDate.Date && x.StaffId == iD) >= 4)
            {
                return(new Result {
                    Success = false, ErrorMsg = "Staff can be available for a maximum of 4 slots per day"
                });
            }

            // Create a slot.
            var newSlot = new Slot {
                RoomName = roomName, StartTime = bookingDate, StaffId = iD
            };

            // SQL to insert the new slot into the DB.
            bool res = ExecuteSql("INSERT INTO [dbo].[Slot] ([RoomID], [StartTime], [StaffID])" +
                                  "VALUES(" +
                                  $"(SELECT RoomID from [Room] where RoomID = '{newSlot.RoomName}')," +
                                  $"'{newSlot.StartTime.ToString(Model.SQLDateTimeFormat)}'," +
                                  $"(SELECT UserID from [User] where UserID = '{newSlot.StaffId}'))");

            if (res)
            {
                Slots.Add(newSlot);
                return(new Result {
                    Success = true
                });
            }
            return(new Result {
                Success = false, ErrorMsg = "Unable to execute database request"
            });
        }