I am trying to obtain data from my html code like the \"acquringCode\", \"cardAcceptor\", and \"merchantId\". I can\'t figure how how to obtain that data in my controller.
Create a viewModel like this one:
public class TreventLocationLookupViewModel
{
public string InstitutionIdentificationCode {get; set;}
public string CardAcceptorIdentificationCode {get; set;}
public string MerchantId {get; set;}
}
and then use it in your Action like that:
public ActionResult AddSaveTreventLocationLookup(TreventLocationLookupViewModel model)
{
AdminProductionServices.TreventLocationLookup treventLocationLookup = Administrator.Models.AdminProduction.TreventLocationLookup.loadTreventLocationLookup(Guid.Empty, Guid.Empty, string.Empty, string.Empty, string.Empty)[0];
treventLocationLookup.acquiringInstitutionIdentifcationCode = model.InstitutionIdentificationCode;
treventLocationLookup.cardAcceptorIdentificationCode = model.CardAcceptorIdentificationCode;
treventLocationLookup.merchantId = model.MerchantId;
Administrator.Models.AdminProduction.TreventLocationLookup.addTreventLocationLookup(treventLocationLookup);
return RedirectToAction("SearchTreventLocationLookup", "Prod");
}
MVC will take care of the binding the request values to the model for you. You should have a read about model binders and validation anyway to get an idea.