private static string PrintStores(MobilePhoneShop iphoneShop, bool isShowPhonesInsideStore, bool isShowEmptyStores) { int currentMobilePhoneStoreIndex = 0; if (iphoneShop.MobilePhoneStores.Length == 0) { Console.WriteLine("=> Please Create some stores - iphoneShop.MobilePhoneStores.Length == 0"); } else { Console.WriteLine($"=> Shop '{iphoneShop.GetDescription()}' has stores:"); foreach (var mobilePhoneStore in iphoneShop.MobilePhoneStores) { bool isMobilePhoneStoreEmpty = mobilePhoneStore == null; if (!isShowEmptyStores && isMobilePhoneStoreEmpty) { continue; } string stringToShow = $"[{currentMobilePhoneStoreIndex}] - Store cell is "; stringToShow += isMobilePhoneStoreEmpty ? "empty" : $"'{mobilePhoneStore.GetDescription()}'"; Console.WriteLine(stringToShow); if (isShowPhonesInsideStore && !isMobilePhoneStoreEmpty) { PrintAllPhonesInStore(mobilePhoneStore); } currentMobilePhoneStoreIndex++; } } return($"=> Stores of a Shop '{iphoneShop}' are printed"); }
private static string AddPhoneToStore(MobilePhoneShop iphoneShop) { if (!IsAnyMobilePhoneStoreAvailable(iphoneShop)) { return($"=> in {iphoneShop.GetDescription()} no real stores are available. Please add any real store before add a phone."); } MobilePhoneStore store = GetMobilePhoneStoreFromInput(iphoneShop); MobilePhone mobilePhone = CreatePhoneFromInput(); bool isPhoneAddedToStore = iphoneShop.AddPhoneToStore(mobilePhone, store.Address); string resultMessage = isPhoneAddedToStore ? "successfully added" : "was not added"; return($"=> Phone with {mobilePhone.GetDescription()} {resultMessage} to store '{store.GetDescription()}'."); }