I've revised my code and question to better reflect what I'm trying to accomplish.
Background: I have different layer interfaces as part of my project.
- Service Layer - handles my business logic, validates entries, (the brains)
- Data Access Layer - simply executes the methods or functions it is passed
- Aspx & aspx.cs files where the methods need to take place (i.e the user interface)
Here is my code for the ConnectionTypeSetup.aspx.cs file, I've also marked the line where there is an error:
protected void uxSaveBtn_Click(object sender, EventArgs e)
{
var accountTrackersvc = new AccountTrackerSvc();
//Insert or update record
var result = ViewState["ConnectionTypeID"] == null ?
accountTrackersvc.InsertConnectionType(uxConnectionTypeDescTxt.Text.Trim(),
CommonSVC.GetUserInfoFormattedFromSession())
/*Error on this line */ : accountTrackersvc.UpdateConnectionType(DataConverter.StringToInteger(ViewState["ConnectionTypeID"].ToString()),
uxConnectionTypeDescTxt.Text.Trim(),
Enums.GetIsDisabledByItemStatusValue(SafeValueAccessor.GetControlValue(uxStatusDdl)),
CommonSVC.GetUserInfoFormattedFromSession(),"Default",false);
//Check result
if(result.Successful)
{
uxInfoMsg.DisplayMessage(result.Message, InfoMessage.InfoMessageType.Success);
BindGridContent();
uxPopupMdl.Hide();
}
else
{
uxModalInfoMsg.DisplayMessage(result.Message, InfoMessage.InfoMessageType.Failure);
uxPopupMdl.Show();
}
// Hide progress indicator
Master.HideProgressIndicator();
The service layer which again handles my business logic is formatted as follows. Please note there are 2 separate methods being used and Insert
and Update
:
public BO.OperationResult InsertConnectionType(string connectionTypeDesc, string createdBy)
{
var operationResult = new BO.OperationResult();
// connection type description required
if (connectionTypeDesc.Trim().Length <= 0)
{
operationResult.Successful = false;
operationResult.Message += "Connection type description is required";
}
//Createdby required
if (createdBy.Trim().Length <= 0)
{
operationResult.Successful = false;
operationResult.Message += "A record has not been saved in the form this entry was created by";
}
if (operationResult.Successful)
{
operationResult.DBPrimaryKey = new DAL.AccountTrackerDAL().InsertConnectionType(connectionTypeDesc.Trim(), createdBy);
operationResult.Message = "Account Access Level Saved Successfully";
}
return operationResult;
}
2nd Business logic Method and code for update:
public BO.OperationResult UpdateConnectionType(int connectionTypeID, string connectionTypeDesc,bool isDisabled,string lastUpdatedBy)
{
var operationResult = new BO.OperationResult();
if (connectionTypeDesc.Trim().Length <= 0)
{
operationResult.Successful = false;
operationResult.Message += "Connection Type Description has not successfully updated.";
}
if (lastUpdatedBy.Trim().Length <= 0)
{
operationResult.Successful = false;
operationResult.Message += "Last updated by must be entered.";
}
if (operationResult.Successful)
{
operationResult.DBPrimaryKey = new DAL.AccountTrackerDAL().UpdateConnectionType(connectionTypeID, lastUpdatedBy, connectionTypeDesc, isDisabled);
operationResult.Message = "Account Access Level Saved Successfully";
}
return operationResult;
}
Lastly, I'll only include the method signitures for the DAL layer as I think that should be enough and not saturate this question with code.
Update ConnectionType
public int UpdateConnectionType(int connectionTypeID, string lastUpdatedBy, string connectionTypeDesc, bool isDisabled)
Insert ConnectionType
public int InsertConnectionType(string connectionTypeDesc, string createdBy)
My current error reads: No overload for method UpdateConnectionType takes 6 arguments. I've tried to default the values only to receive this error. Any feedback would be appreciated, thanks!
See Question&Answers more detail:
os