I have a ViewModel
, Controller and View like below:
public class H2HViewModel
{
public DateTime EffectiveDate { get; set; }
public byte TransferMethod { get; set; }
public string ListOfSelectedBatchID { get; set; }
}
Controller:
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create(H2HViewModel model)
{
var detailPayments = db.Payments.Where(x => x.Status == 2).ToList();
foreach (Payment detail in detailPayments)
{
detail.PaymentStatus = 4;
detail.EffectiveDate = model.EffectiveDate;
detail.TransferMethod = model.TransferMethod.ToString();
}
db.SaveChanges();
return RedirectToAction("Dashboard", "User");
}
View
@model EPayment.Data.ViewModels.H2HViewModel
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
@Html.EditorFor(model => model.EffectiveDate, new { @class = "form-control dtpicker" })
<div class="col-md-10">
@Html.RadioButtonFor(model => model.TransferMethod, "AB", new { htmlAttributes = new { @class = "form -control" } }) AB
@Html.RadioButtonFor(model => model.TransferMethod, "BC", new { htmlAttributes = new { @class = "form -control" } }) BC
</div>
<input type="submit" value="Submit" class="btn btn-default"/>
}
When I click the submit button nothing happens,
I made a breakpoints on ActionResult
's create to debug it, but nothing happened.
I refer to this stackoverflow.com/questions/16443927, and have done it but it didn't work, any idea?