public void Call(MobileAccount toMobileAccount) { Console.WriteLine($"Calling from mobile number { mobileNumber } to number { toMobileAccount.mobileNumber }"); if (CallSomeone != null) { CallSomeone(toMobileAccount, new AccountEventArgs(mobileNumber)); } }
public void SendSMS(MobileAccount toMobileAccount, string message) { Console.WriteLine($"From mobile number { mobileNumber } to mobile number { toMobileAccount.mobileNumber }. Message \"{ message }\""); if (SentSMS != null) { SentSMS(toMobileAccount, new AccountEventArgs(mobileNumber, message)); } }
public MobileAccount CreateAccount(int number) { var acc = new MobileAccount(number, this); _accounts.Add(number, acc); acc.OnMessagePost += RouteMessage; acc.OnCall += RouteCall; return(acc); }
private bool ContainsAccount(MobileAccount mobileAcc) { for (int i = 0; i < users.Length; i++) { if (users[i].mobileNumber.Equals(mobileAcc.mobileNumber)) { return(true); } } return(false); }
public void RouteCall(MobileAccount toMobileAccout, AccountEventArgs eventArgs) { if (ContainsAccount(toMobileAccout)) { Console.WriteLine($"Calling to { toMobileAccout.mobileNumber }."); toMobileAccout.TakeCall(eventArgs.fromWhomNumber); interactions.Add(new Interaction(eventArgs.fromWhomNumber, toMobileAccout.mobileNumber, InteractionType.Call)); } else { Console.WriteLine("Dialed phone number does not exist."); } }
public void RouteSMS(MobileAccount toMobileAccout, AccountEventArgs eventArgs) { if (ContainsAccount(toMobileAccout)) { Console.WriteLine($"Sending SMS to { toMobileAccout.mobileNumber }. Message \"{ eventArgs.message }\""); toMobileAccout.ReceiveSMS(eventArgs.fromWhomNumber, eventArgs.message); interactions.Add(new Interaction(eventArgs.fromWhomNumber, toMobileAccout.mobileNumber, InteractionType.SMS)); } else { Console.WriteLine("Such phone number does not exist."); } }