Пример #1
0
 public Boolean addNewGp(int gpID, string firstName, string lastName, string address, string phone, string email)
 {
     try
     {
         int maxId = 0;
         //need some code to avoid dulicate usernames
         //maybe add some logic (busiess rules) about password policy
         //IUser user = new User(name, password, userType); // Construct a User Object
         foreach (Gp gp in GpList)
         {
             if (gp.GpID > maxId)
             {
                 maxId = gp.GpID;
             }
         }
         IGp theGp = GpFactory.GetGp(maxId + 1, firstName, lastName, address, phone, email); // Using a Factory to create the user entity object. ie seperating object creation from business logic
         GpList.Add(theGp);                                                                  // Add a reference to the newly created object to the Models UserList
         DataLayer.addNewGpToDB(theGp);                                                      //Gets the DataLayer to add the new user to the DB.
         return(true);
     }
     catch (System.Exception excep)
     {
         return(false);
     }
 }
Пример #2
0
 public bool deleteGp(IGp gp)
 {
     DataLayer.deleteGpFromDB(gp);
     GpList.Remove(gp); //remove object from collection
     return(true);
 }