Esempio n. 1
0
 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));
     }
 }
Esempio n. 2
0
 public void Call(MobileAccount toMobileAccount)
 {
     Console.WriteLine($"Calling from mobile number { mobileNumber } to number { toMobileAccount.mobileNumber }");
     if (CallSomeone != null)
     {
         CallSomeone(toMobileAccount, new AccountEventArgs(mobileNumber));
     }
 }
Esempio n. 3
0
        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);
            }
        }
Esempio n. 4
0
 private bool ContainsAccount(MobileAccount mobileAcc)
 {
     for (int i = 0; i < users.Count; i++)
     {
         if (users[i].mobileNumber.Equals(mobileAcc.mobileNumber))
         {
             return(true);
         }
     }
     return(false);
 }
Esempio n. 5
0
 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.");
     }
 }
Esempio n. 6
0
 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.");
     }
 }
Esempio n. 7
0
        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);
            }
        }