public void Create(Terminal terminal)
 {
     try
     {
         if (!String.IsNullOrEmpty(terminal.Name) && terminal.Location != null)
         {
             if (terminal.Location.IdLocation > 0)
             {
                 LocCRUD.Update(terminal.Location);
             }
             else
             {
                 LocCRUD.Create(terminal.Location);
                 terminal.Location = LocCRUD.RetrieveLast <Location>();
             }
             CrudFactory.Create(terminal);
         }
         else
         {
             // Both Terminal Name and Location are required.
             throw new BusinessException(22);
         }
     }
     catch (Exception ex)
     {
         ExceptionManager.GetInstance().Process(ex);
     }
 }
        public Location RetrieveLast()
        {
            Location be = null;

            try
            {
                be = CrudFactory.RetrieveLast <Location>();
                if (be == null)
                {
                    // There are no Locations registered
                    throw new BusinessException(25);
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.GetInstance().Process(ex);
            }

            return(be);
        }