Hi,
I am using MVC 2 and EF 4.
I am trying to update my Application entity using my own stored procedure, but it is not updating. I checked out SQL Profiler and it is not even reaching the database. I also use an insert stored procedure and it works fine. Both stored procedures (insert and update) are mapped correctly. Does anyone know what I am doing wrong?
Here is my EditApplication action event:
[HttpPost]
public ActionResult EditApplication(int id, ApplicationViewModel applicationViewModel)
{
if (ModelState.IsValid)
{
try
{
Mapper.CreateMap<ApplicationViewModel, Application>();
var application = (Application)Mapper.Map(applicationViewModel, typeof(ApplicationViewModel), typeof(Application));
application.ApplicationID = id;
UpdateModel(application);
// Edit application
applicationRepository.UpdateApplication(application);
// If success, redirect to confirmation page
return RedirectToAction("Confirmation", new { id = application.ApplicationID });
}
catch (Exception ex)
{
// TODO
}
}
applicationViewModel.AccountTypes = accountTypeRepository.GetAccountTypes();
return View("CreateApplication", applicationViewModel);
}
Here is my repository Update method:
private MyEntities db = new MyEntities();
public void UpdateApplication(Application application)
{
db.SaveChanges();
}
Thanks Brendan