Reputation: 621
I have some stored procedure to add information to a database already. Now I am creating a webpage that allows a user to view certain items within the database. When a user view the page, he or she have the option to edit/update or add a new merchant. I am having difficulties in the controller my method is not taking in the parameters im giving it. If you have any clues or know the answer please share.. Thank You
P.S Whener I hover over the add function it says bool MerchantTypeRef.addMerchantTypeRef(MerchantAdminProductionServices.MerchantTypeRef merchantTypeRef)
Error: The best overloaded method match for 'MerchantAdministrator.Models.MerchantAdminProduction.MerchatTypeRef.addMerchantTypeRef(MerchantAdministrator.MerchantAdminProductionServices.MerchantTypeRef)' has some invalid arguments
Controller
[MerchantAuthorizeAttribute(AdminRoles = "AddMerchantTypeRef")]
public ActionResult AddMerchantTypeRef()
{
try
{
Guid merchantTypeRefId = Request["merchantTypeRefId"] != null ? new Guid(Request["merchantTypeRefId"]) : Guid.Empty;
string name = Request["name"]?? string.Empty;
string description = Request["description"]?? string.Empty;
string xMerchantType = Request["xMerchantTypeRefCode"]??string.Empty;
DarkstarAdministrator.DarkstarAdminProductionServices.MerchantTypeRef merchantTypeRef = new DarkstarAdministrator.DarkstarAdminProductionServices.MerchantTypeRef();
merchantTypeRef.name = name;
merchantTypeRef.description = description;
merchantTypeRef.xMerchantTypeCode = xMerchantType;
ViewBag.addMerchantTypeRef = MerchantAdministrator.Models.MerchantAdminProduction.MerchantTypeRef.addMerchantTypeRef(merchantTypeRef); <------This where I have the Trouble . not reading parameter
}
catch (Exception e)
{
Commons.ErrorHandling.ReportError("MerchantAdministrator.Controllers.ProdController AddMerchantTypeRef()", e);
}
return View();
}
Model
public static bool addMerchantTypeRef(DarkstarAdminProductionServices.MerchantTypeRef merchantTypeRef)
{
try
{
DarkstarAdminProductionServices.DarkstarAdminProductionServicesSoapClient client = new DarkstarAdminProductionServices.DarkstarAdminProductionServicesSoapClient();
return client.addMerchantTypeRef(merchantTypeRef);
}
catch (Exception e)
{
Commons.ErrorHandling.ReportError("MerchantTypeRef.addMerchantTypeRef()", e);
}
return false;
}
Reference
[System.Runtime.Serialization.DataMemberAttribute(IsRequired=true)]
public System.Guid merchantTypeRefId {
get {
return this.merchantTypeRefIdField;
}
set {
if ((this.merchantTypeRefIdField.Equals(value) != true)) {
this.merchantTypeRefIdField = value;
this.RaisePropertyChanged("merchantTypeRefId");
}
}
}
[System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false)]
public string name {
get {
return this.nameField;
}
set {
if ((object.ReferenceEquals(this.nameField, value) != true)) {
this.nameField = value;
this.RaisePropertyChanged("name");
}
}
}
[System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false, Order=2)]
public string description {
get {
return this.descriptionField;
}
set {
if ((object.ReferenceEquals(this.descriptionField, value) != true)) {
this.descriptionField = value;
this.RaisePropertyChanged("description");
}
}
}
[System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false, Order=3)]
public string xMerchantTypeCode
{
get {
return this.xMerchantTypeCodeField;
}
set {
if ((object.ReferenceEquals(this.xMerchantTypeCodeField, value) != true)) {
this.xMerchantTypeCodeField = value;
this.RaisePropertyChanged("xMerchantTypeCode");
}
}
}
View
<script type="text/javascript">
$(document).ready(function () {
$("#merchantTypeUpdateButton").click(function () {
$("#updateMerchantType").submit();
});
});
<%MerchantAdministrator.MerchantAdminProductionServices.MerchantTypeRef EditMerchantType = ViewBag.MerchantTypeRefEdit !=null ? ViewBag.MerchantTypeRefEdit: new MerchantAdministrator.DarkstarAdminProductionServices.MerchantTypeRef(); %>
<form id="updateMerchantType" action="<%=Url.Action("EditMerchantTypePost","Prod") %>? merchantTypeRefId"=<%=EditMerchantType.merchantTypeRefId %>" method="post">
<table>
<tr>
<td colspan="3" class="tableHeader">Merchant Type Ref Details</td>
</tr>
<tr>
<td colspan="2" class="label">Name:</td>
<td class="content">
<input type="text" maxlength="100" name="Name" value=" <%=EditMerchantType.name %>" />
</td>
</tr>
<tr>
<td colspan="2" class="label">Description:</td>
<td class="content">
<input type="text" maxlength="2000" name="Description" value="<%=EditMerchantType.description %>" />
</td>
</tr>
<tr>
<td colspan="2" class="label">Merchant Type Code:</td>
<td class="content">
<input type="text" maxlength="5" name="XMerchantTypeCode" value="<%=EditMerchantType.xMerchantTypeCode %>" />
</td>
</tr>
<tr>
<td colspan="3" class="tableFooter">
<br />
<a id="merchantTypeUpdateButton" href="#" class="regularButton">Save</a>
<a href="javascript:history.back()" class="regularButton">Cancel</a>
</td>
</tr>
</table>
Upvotes: 0
Views: 159
Reputation: 948
bool ViewBag.addMerchantTypeRef = MerchantAdministrator.Models.MerchantAdminProduction.MerchantTypeRef.addMerchantTypeRef(merchantTypeRef);
Can you please tell me is this "merchantTypeRef" or "merchantTypeRefId"? Because merchantTypeRefId is what read by the first line and the same value will need to be passed when you call Model. If that doesn't work, can you please try with "FormCollection"?
Upvotes: 1