Exemplo n.º 1
0
        public static string Edit(ref int opt, Person_phone phone, string text)
        {
            switch (opt)
            {
            case 1:
                try
                {
                    phone.countryCode = (int)Enum.Parse(typeof(Country), text);
                    return(Save());
                }
                catch (Exception ex)
                {
                    logger.Error(ex, "DatabaseAction.Edit BadInput Error");
                    return("Invalid Country!");
                }

            case 2:
                phone.areaCode = text;
                return(Save());

            case 3:
                phone.number = text;
                return(Save());

            case 4:
                phone.ext = text;
                return(Save());

            default:
                return("No Information Updated");
            }
        }
Exemplo n.º 2
0
 public static Person_phone AddNewContact(Person p, int countrycode, string areacode, string number, string ext)
 {
     pp = new Person_phone
     {
         Person      = p,
         countryCode = countrycode,
         areaCode    = areacode,
         number      = number,
         ext         = ext
     };
     return(pp);
 }
Exemplo n.º 3
0
 public static Person_phone FindPhoneID(int ID)
 {
     try
     {
         Person_phone phone = db.Person_phone.Single(pp => pp.PHid == ID);
         return(phone);
     }
     catch (Exception ex)
     {
         logger.Error(ex, "DatabaseAction.Find Null Error");
         return(null);
     }
 }
Exemplo n.º 4
0
 public static void AddToDatabase(Person_phone pp)
 {
     db.Person_phone.Add(pp);
 }
Exemplo n.º 5
0
 public static string Del(Person_phone phone)
 {
     db.Person_phone.Remove(phone);
     return(Save());
 }
        public static void UpdateOption(int up_del)
        {
            int    opt = 0;
            int    id;
            int    updateOpt;
            string updateText;

            do
            {
                if (up_del == 1)
                {
                    Console.WriteLine("\nUpdate:");
                }
                else
                {
                    Console.WriteLine("\nDelete:");
                }
                Console.WriteLine("1. PERSON | 2. PHONE | 3. ADDRESS | 4.BACK");
                switch (opt = ConvertCheck())
                {
                case 1:
                    Console.WriteLine("\nEnter Person ID: ");
                    id = ConvertCheck();
                    Person p = DatabaseAction.FindPersonID(id);
                    if (p != null && up_del == 1)
                    {
                        Console.WriteLine("Select Following Fields:");
                        updateOpt  = PersonOpt();
                        updateText = Add("Text");
                        Console.WriteLine(DatabaseAction.Edit(ref updateOpt, p, updateText));
                    }
                    else if (p != null && up_del == 2)
                    {
                        Console.WriteLine(DatabaseAction.Del(p));
                    }
                    else if (p == null)
                    {
                        Console.WriteLine("No Records Found!");
                    }
                    break;

                case 2:
                    Console.WriteLine("\nEnter Phone ID: ");
                    id = ConvertCheck();
                    Person_phone pp = DatabaseAction.FindPhoneID(id);
                    if (pp != null && up_del == 1)
                    {
                        Console.WriteLine("Select Following Fields:");
                        updateOpt  = PhoneOpt();
                        updateText = Add("Text");
                        Console.WriteLine(DatabaseAction.Edit(ref updateOpt, pp, updateText));
                    }
                    else if (pp != null && up_del == 2)
                    {
                        Console.WriteLine(DatabaseAction.Del(pp));
                    }
                    else if (pp == null)
                    {
                        Console.WriteLine("No Records Found!");
                    }
                    break;

                case 3:
                    Console.WriteLine("\nEnter Address ID: ");
                    id = ConvertCheck();
                    Person_address pa = DatabaseAction.FindAddressID(id);
                    if (pa != null && up_del == 1)
                    {
                        Console.WriteLine("Select Following Fields:");
                        updateOpt  = AddressOpt();
                        updateText = Add("Text");
                        Console.WriteLine(DatabaseAction.Edit(ref updateOpt, pa, updateText));
                    }
                    else if (pa != null && up_del == 2)
                    {
                        Console.WriteLine(DatabaseAction.Del(pa));
                    }
                    else if (pa == null)
                    {
                        Console.WriteLine("\nNo Records Found!");
                    }
                    break;

                case 4:
                    break;

                default:
                    Console.WriteLine("Invalid Option!");
                    break;
                }
            } while (opt != 4);
        }