Exemple #1
0
 // the following code connects with the update function in the DataAccess logic through the BusinessLogic
 private void UpdateOwner(int id, string ownername, string petname, int petage, string contactphone, string firstname, string lastname, string username, string password, int age, string email, string role)
 {
     try
     {
         using (var owners = new OwnersBusiness())
         {
             var entity = new OwnersEntity();
             entity.OwnerID      = id;
             entity.OwnerName    = ownername;
             entity.PetName      = petname;
             entity.PetAge       = petage;
             entity.ContactPhone = contactphone;
             entity.FirstName    = firstname;
             entity.LastName     = lastname;
             entity.Username     = username;
             entity.Password     = password;
             entity.Age          = age;
             entity.Email        = email;
             entity.Role         = role;
             var opSuccessful = owners.UpdateOwner(entity);
         }
     }
     catch (Exception ex)
     {
         //Log exception error
         _loggingHandler.LogEntry(ExceptionHandler.GetExceptionMessageFormatted(ex), true);
     }
 }
Exemple #2
0
        private void Update(int id, string ownername, string petname, int age, string contactphone)
        {
            try
            {
                using (var owners = new OwnersBusiness())
                {
                    var entity = new OwnersEntity();
                    entity.OwnerID      = id;
                    entity.OwnerName    = ownername;
                    entity.PetName      = petname;
                    entity.PetAge       = age;
                    entity.ContactPhone = contactphone;
                    var opSuccessful = owners.UpdateOwner(entity);

                    var resultMessage = opSuccessful ? "Done Successfully" : "Error happened or no Owner found to update";

                    MessageBox.Show(resultMessage, "Success", MessageBoxButtons.OK);
                }
            }
            catch (Exception ex)
            {
                //Log exception error
                _loggingHandler.LogEntry(ExceptionHandler.GetExceptionMessageFormatted(ex), true);

                MessageBox.Show("UserInterface:OwnersForm::Update::Error occured." +
                                Environment.NewLine + ex.Message, "Error", MessageBoxButtons.OK);
            }
        }
Exemple #3
0
 // the following code connects with the delete function in the DataAccess logic through the BusinessLogic
 private void DeleteOwner(int id)
 {
     try
     {
         using (var owners = new OwnersBusiness())
         {
             var opSuccessful = owners.DeleteOwnerById(id);
         }
     }
     catch (Exception ex)
     {
         //Log exception error
         _loggingHandler.LogEntry(ExceptionHandler.GetExceptionMessageFormatted(ex), true);
     }
 }
Exemple #4
0
 // the following code connects with the selectbyID function the the DataAccess logic through the BusinessLogic
 private OwnersEntity SelectOwnerById(int id)
 {
     try
     {
         using (var owners = new OwnersBusiness())
         {
             return(owners.SelectOwnerById(id));
         }
     }
     catch (Exception ex)
     {
         //Log exception error
         _loggingHandler.LogEntry(ExceptionHandler.GetExceptionMessageFormatted(ex), true);
     }
     return(null);
 }
Exemple #5
0
        private List <OwnersEntity> SelectAll()
        {
            try
            {
                using (var owners = new OwnersBusiness())
                {
                    return(owners.SelectAllOwners());
                }
            }
            catch (Exception ex)
            {
                //Log exception error
                _loggingHandler.LogEntry(ExceptionHandler.GetExceptionMessageFormatted(ex), true);

                MessageBox.Show("UserInterface:OwnersForm::SelectAll::Error occured." +
                                Environment.NewLine + ex.Message, "Error", MessageBoxButtons.OK);
            }
            return(null);
        }
Exemple #6
0
        private void Delete(int id)
        {
            try
            {
                using (var owners = new OwnersBusiness())
                {
                    bool opSuccessful = owners.DeleteOwnerById(id);

                    var resultMessage = opSuccessful ? "Done Successfully" : "Error happened or no Owner found to delete";

                    MessageBox.Show(resultMessage, "Success", MessageBoxButtons.OK);
                }
            }
            catch (Exception ex)
            {
                //Log exception error
                _loggingHandler.LogEntry(ExceptionHandler.GetExceptionMessageFormatted(ex), true);

                MessageBox.Show("UserInterface:OwnersForm::Delete::Error occured." +
                                Environment.NewLine + ex.Message, "Error", MessageBoxButtons.OK);
            }
        }