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); } } }
public ChangeShelfNumberStatusCodes ChangeShelfNumber(int shelfID, int shelfNumber) { var currentShelf = shelfManager.GetShelfByShelfId(shelfID); if (currentShelf == null) { return(ChangeShelfNumberStatusCodes.NoSuchShelf); } if (currentShelf.ShelfNumber == shelfNumber) { return(ChangeShelfNumberStatusCodes.CanNotChangeToSameNumber); } shelfManager.ChangeShelfNumber(shelfID, shelfNumber); return(ChangeShelfNumberStatusCodes.Ok); }