Exemplo n.º 1
0
        // Borrow (return string with message (user + item) if it's working)
        public Respone <string> Return(HardCopy data)
        {
            Respone <string> feedback;
            // find user id in borrowed items
            HardCopy tempdata;

            if (!_borrowedHardCopies.TryGetValue(data.CopyId, out tempdata))
            {
                feedback               = new Respone <string>();
                feedback.IsWorking     = false;
                feedback.Message       = "Missing or invalid data";
                feedback.WrongDataType = WrongData.CopyId;
                return(feedback);
            }
            else
            {
                data.BorrowerId = tempdata.BorrowerId;
            }

            User         user;
            AbstractItem item;

            feedback = CheckAndSearchItemAndUser(data, out user, out item);
            if (!feedback.IsWorking)
            {
                return(feedback);
            }
            else
            {
                Respone <HardCopy> tempFeedback = BorrowReturnOperations <HardCopy> .Return(data, item, user);

                if (!tempFeedback.IsWorking)
                {
                    feedback.IsWorking = false;
                    feedback.Message   = tempFeedback.Message;
                }
                else
                {
                    // remove hard-copy data from borrowed-dictionary
                    _borrowedHardCopies.Remove(tempFeedback.Data.CopyId);
                    feedback.Data = tempFeedback.Message;
                }

                return(feedback);
            }
        }
Exemplo n.º 2
0
        // Borrow (return string with message (user + item) if it's working)
        public Respone <string> Borrow(HardCopy data)
        {
            User             user;
            AbstractItem     item;
            Respone <string> feedback = CheckAndSearchItemAndUser(data, out user, out item);

            if (!feedback.IsWorking)
            {
                return(feedback);
            }
            else
            {
                Respone <HardCopy> tempFeedback = BorrowReturnOperations <HardCopy> .Borrow(data, item, user);

                if (!tempFeedback.IsWorking)
                {
                    feedback.IsWorking = false;
                    feedback.Message   = tempFeedback.Message;
                }
                else
                {
                    // add hard-copy data to borrowed-dictionary
                    if (_borrowedHardCopies.ContainsKey(tempFeedback.Data.CopyId))
                    {
                        _borrowedHardCopies[tempFeedback.Data.CopyId] = tempFeedback.Data;
                    }
                    else
                    {
                        _borrowedHardCopies.Add(tempFeedback.Data.CopyId, tempFeedback.Data);
                    }

                    feedback.Data = tempFeedback.Message;
                }

                return(feedback);
            }
        }