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 void AddAccount(string fName, string lName, string email, DateTime birthday) { string mobileNumber = GenerateMobileNum(); var newAccount = new MobileAccount(mobileNumber, fName, lName, email, birthday); if (MobileAccount.Validate(newAccount)) { users.Add(newAccount); } }
private bool ContainsAccount(MobileAccount mobileAcc) { for (int i = 0; i < users.Count; 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."); } }
public static bool Validate(MobileAccount mobileAccount) { var results = new List <ValidationResult>(); var context = new ValidationContext(mobileAccount); if (!Validator.TryValidateObject(mobileAccount, context, results, true)) { foreach (var error in results) { Console.WriteLine(error.ErrorMessage); } return(false); } else { return(true); } }