Example #1
0
        public IPackage PickUpPackage(string code)
        {
            if (!FilledLockers.ContainsKey(code))
            {
                throw new Exception("Code is not exist");
            }
            ILocker locker = FilledLockers[code];

            locker.Open();
            IPackage package = locker.RetrievePackage();

            locker.Close();
            FilledLockers.Remove(code);
            AddLocker(locker);

            return(package);
        }
Example #2
0
        public void PutPackage(IPackage package, User user)
        {
            ILocker locker = GetAvailableLocker(package.Size);

            locker.Open();
            locker.PutPackage(package, user);
            locker.Close();
            string code = GenerateCode(CodeLen);

            while (!FilledLockers.ContainsKey(code))
            {
                code = GenerateCode(CodeLen);
            }
            FilledLockers[code] = locker;
            Notification notification = new Notification(code, package, user, locker);

            SendNotification(notification);
        }