示例#1
0
        public ActionConfirmation SaveOrUpdate(Org org)
        {
            if (org.IsValid())
            {
                ValidateOrg(org);
                _orgRepository.SaveOrUpdate(org);

                ActionConfirmation saveOrUpdateConfirmation = ActionConfirmation.CreateSuccessConfirmation(
                    "The org was successfully saved.");
                saveOrUpdateConfirmation.Value = org;

                return(saveOrUpdateConfirmation);
            }
            else
            {
                _orgRepository.DbContext.RollbackTransaction();

                return(ActionConfirmation.CreateFailureConfirmation(
                           "The org could not be saved due to missing or invalid information."));
            }
        }
示例#2
0
        public ActionConfirmation UpdateWith(Org orgFromForm, int idOfOrgToUpdate)
        {
            Org orgToUpdate =
                _orgRepository.Get(idOfOrgToUpdate);

            ValidateOrg(orgFromForm);
            TransferFormValuesTo(orgToUpdate, orgFromForm);

            if (orgToUpdate.IsValid())
            {
                ActionConfirmation updateConfirmation = ActionConfirmation.CreateSuccessConfirmation(
                    "The org was successfully updated.");
                updateConfirmation.Value = orgToUpdate;

                return(updateConfirmation);
            }
            else
            {
                _orgRepository.DbContext.RollbackTransaction();

                return(ActionConfirmation.CreateFailureConfirmation(
                           "The org could not be saved due to missing or invalid information."));
            }
        }