Esempio n. 1
0
        public ShelfErrorCodes ChangeShelf(int shelfID, int hallID = 0, int shelfNumber = 0)
        {
            var shelf = shelfManager.GetShelf(shelfID);

            if (shelf == null)
            {
                return(ShelfErrorCodes.NoSuchShelf);
            }
            else
            {
                if (hallID != 0)
                {
                    var existingHall = hallManager.GetHall(hallID);
                    if (existingHall == null)
                    {
                        return(ShelfErrorCodes.NoSuchHall);
                    }
                    shelfManager.ChangeShelfHall(shelf, hallID);
                    return(ShelfErrorCodes.TheShelfHasChangedHall);
                }
                else
                {
                    var existingShelfNumber = shelfManager.GetShelfByShelfNumber(shelf.HallID, shelfNumber);
                    if (existingShelfNumber != null)
                    {
                        return(ShelfErrorCodes.ShelfNumberOccupied);
                    }
                    else
                    {
                        shelfManager.ChangeShelfNumber(shelf, shelfNumber);
                    }
                    return(ShelfErrorCodes.TheShelfNumberHasBeenChanged);
                }
            }
        }