public static int Registe(string firstName, string lastName, string phone, string city) { int ID = -1; //check if the customer already existing Customers.ForEach(c => { ID = (c.FirstName == firstName && c.LastName == lastName) ? c.ID : ID; }); //new customer, create record and return new ID. if (ID == -1) { Customer newCus = new Customer() { FirstName = firstName, LastName = lastName, Phone = phone, City = city }; try { ID = GenericDB.GenericInsert <Customer>("Customer", newCus); } catch (Exception ex) { throw new Exception(ex.Message, ex); } } return(ID); }
/// <summary> /// add new lease to DB /// </summary> /// <param name="customerID"></param> /// <param name="slipId"></param> public static void addLease(int customerID, int slipId) { Lease newLease = new Lease() { CustomerID = customerID, SlipID = slipId, }; try { GenericDB.GenericInsert <Lease>("Lease", newLease); Leases = GenericDB.GenericRead <Lease>("Lease");//Static Leases, so need update Leases after each insert. } catch (Exception ex) { throw new Exception(ex.Message, ex); } }