Beispiel #1
0
 public static Person_address FindAddressID(int ID)
 {
     try
     {
         Person_address address = db.Person_address.Single(pa => pa.Aid == ID);
         return(address);
     }
     catch (Exception ex)
     {
         logger.Error(ex, "DatabaseAction.Find Null Error");
         return(null);
     }
 }
Beispiel #2
0
 public static Person_address AddNewContact(Person p, string hnum, string street, string city, string state, string country, string zipcode)
 {
     pa = new Person_address
     {
         houseNum        = hnum,
         street          = street,
         address_city    = city,
         address_state   = state,
         address_country = country,
         zipcode         = zipcode
     };
     pa.People.Add(p);
     return(pa);
 }
Beispiel #3
0
        public static string Edit(ref int opt, Person_address address, string text)
        {
            switch (opt)
            {
            case 1:
                address.houseNum = text;
                return(Save());

            case 2:
                address.street = text;
                return(Save());

            case 3:
                address.address_city = text;
                return(Save());

            case 4:
                try
                {
                    address.address_state = Enum.GetName(typeof(State), Enum.Parse(typeof(State), text));
                    return(Save());
                }
                catch (Exception ex)
                {
                    logger.Error(ex, "DatabaseAction.Edit BadInput Error");
                    return("Invalid State!");
                }

            case 5:
                try
                {
                    address.address_country = Enum.GetName(typeof(Country), Enum.Parse(typeof(Country), text));
                    return(Save());
                }
                catch (Exception ex)
                {
                    logger.Error(ex, "DatabaseAction.Edit BadInput Error");
                    return("Invalid Country!");
                }

            case 6:
                address.zipcode = text;
                return(Save());

            default:
                return("No Information Updated");
            }
        }
Beispiel #4
0
 public static void AddToDatabase(Person_address pa)
 {
     db.Person_address.Add(pa);
 }
Beispiel #5
0
 public static string Del(Person_address address)
 {
     db.Person_address.Remove(address);
     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);
        }