public Enumerations.MemberCaseActionOutcome AddIntervention(Int64 copyCareInterventionId, String carePlanInterventionName) { // BUSINESS RULES FOR ADDING A PROBLEM STATEMENT TO A MEMBER CASE // TODO: DOCUMENT BUSINESS RULES Enumerations.MemberCaseActionOutcome outcome = Enumerations.MemberCaseActionOutcome.UnknownError; // DO NOT USE TRANSACTIONS, SERIALIZABLE TRANSACTION SUPPORTED THROUGH STORED PROCEDURE DateTime lastModifiedDate = modifiedAccountInfo.ActionDate; try { // NO VALIDATION REQUIRED System.Data.IDbCommand sqlCommand = application.EnvironmentDatabase.CreateCommand("dbo.MemberCaseCarePlanIntervention_Add"); sqlCommand.CommandType = System.Data.CommandType.StoredProcedure; application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@memberCaseCarePlanId", Id); application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@copyCareInterventionId", copyCareInterventionId); application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@carePlanInterventionName", carePlanInterventionName, 60); application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@ignoreAssignedTo", false); application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@modifiedAuthorityId", application.Session.SecurityAuthorityId); application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@modifiedAuthorityName", application.Session.SecurityAuthorityName, Server.Data.DataTypeConstants.Name); application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@modifiedAccountId", application.Session.UserAccountId, Server.Data.DataTypeConstants.UserAccountId); application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@modifiedAccountName", application.Session.UserAccountName, Server.Data.DataTypeConstants.Name); application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@lastModifiedDate", lastModifiedDate); // RETURNED MODIFIED DATE application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@modifiedDate", ((DateTime?)null)); ((System.Data.IDataParameter)sqlCommand.Parameters["@modifiedDate"]).Direction = System.Data.ParameterDirection.Output; // RETURN VALUE application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@RETURN", ((Int32)0)); ((System.Data.IDataParameter)sqlCommand.Parameters["@RETURN"]).Direction = System.Data.ParameterDirection.ReturnValue; sqlCommand.ExecuteNonQuery(); outcome = (Enumerations.MemberCaseActionOutcome)(Convert.ToInt32(((System.Data.IDataParameter)sqlCommand.Parameters["@RETURN"]).Value)); MemberCase.SetApplicationException(outcome, "Care Plan Intervention"); if (outcome == Enumerations.MemberCaseActionOutcome.Success) { Load(id); } // ON SUCCESS - RELOAD OBJECT } catch (Exception applicationException) { outcome = Enumerations.MemberCaseActionOutcome.UnknownError; base.application.SetLastException(applicationException); } return(outcome); }
public Enumerations.MemberCaseActionOutcome SaveUpdate(Boolean ignoreAssignedTo = false) { Enumerations.MemberCaseActionOutcome outcome = Enumerations.MemberCaseActionOutcome.UnknownError; // DO NOT USE TRANSACTIONS, SERIALIZABLE TRANSACTION SUPPORTED THROUGH STORED PROCEDURE DateTime lastModifiedDate = modifiedAccountInfo.ActionDate; try { Dictionary <String, String> validationResponse = Validate(); if (validationResponse.Count != 0) { foreach (String validationKey in validationResponse.Keys) { application.SetLastExceptionQuite(new ApplicationException("Invalid [" + validationKey + "]: " + validationResponse[validationKey])); return(Enumerations.MemberCaseActionOutcome.ValidationError); } } modifiedAccountInfo = new Data.AuthorityAccountStamp(application.Session); // ATTEMPT TO SAVE NEW OR UPDATE EXISTING ENTITY ADDRESS System.Data.IDbCommand sqlCommand = application.EnvironmentDatabase.CreateCommand("dbo.MemberCaseCarePlanGoal_Update"); sqlCommand.CommandType = System.Data.CommandType.StoredProcedure; application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@memberCaseCarePlanGoalId", Id); application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@status", ((Int32)Status)); application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@memberCaseCarePlanGoalName", Name, Server.Data.DataTypeConstants.Name); application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@memberCaseCarePlanGoalDescription", Description, Server.Data.DataTypeConstants.Description); application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@ignoreAssignedTo", ignoreAssignedTo); application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@modifiedAuthorityId", application.Session.SecurityAuthorityId); application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@modifiedAuthorityName", ModifiedAccountInfo.SecurityAuthorityName, Server.Data.DataTypeConstants.Name); application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@modifiedAccountId", ModifiedAccountInfo.UserAccountId, Server.Data.DataTypeConstants.UserAccountId); application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@modifiedAccountName", ModifiedAccountInfo.UserAccountName, Server.Data.DataTypeConstants.Name); application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@lastModifiedDate", lastModifiedDate); // RETURNED MODIFIED DATE application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@modifiedDate", ((DateTime?)null)); ((System.Data.IDbDataParameter)sqlCommand.Parameters["@modifiedDate"]).Direction = System.Data.ParameterDirection.Output; // RETURN VALUE application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@RETURN", ((Int32)0)); ((System.Data.IDbDataParameter)sqlCommand.Parameters["@RETURN"]).Direction = System.Data.ParameterDirection.ReturnValue; sqlCommand.ExecuteNonQuery(); outcome = (Enumerations.MemberCaseActionOutcome)(Convert.ToInt32(((System.Data.IDbDataParameter)sqlCommand.Parameters["@RETURN"]).Value)); // TODO: SET APPLICATION EXCEPTION // SetApplicationException (outcome); if (outcome == Enumerations.MemberCaseActionOutcome.Success) { // UPDATE MODIFIED DATE FROM STORED PROCEDURE RESULTS modifiedAccountInfo.ActionDate = Convert.ToDateTime(((System.Data.IDbDataParameter)sqlCommand.Parameters["@modifiedDate"]).Value); } // DO NOT SET ID, THIS IS AN UPDATE ONLY PROCEDURE } catch (Exception applicationException) { outcome = Enumerations.MemberCaseActionOutcome.UnknownError; base.application.SetLastException(applicationException); } return(outcome); }