I am using jqgrid Modal form to Add and Edit rows of the table. I am using Entity framework and Database First approach to create models from existing database. When I Add or Edit the rows, rows are added or edited correctly and being saved appropriately in the database and when I retrieve the added or edited rows and view in jqGrid, they are displayed correctly. But, the only issue is when I Add or Edit, it throws error Status: 'Internal Server Error'. Error Code: 500 in the modal form.
Anyone has any idea of why is this happening? Since, the add or edit is happening properly, is there a way that I can ignore this error message and make it not displayed at all?
Any help is greatly appreciated!
EDIT:
public ActionResult Create(string oper, string id, Employee employee)
{
try
{
if (oper == "add")
{
if (ModelState.IsValid)
{
db.Employees.Add(employee);
db.SaveChanges();
return RedirectToAction("Index");
}
}
if (oper == "edit")
{
if (ModelState.IsValid)
{
db.Entry(employee).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
}
if (oper == "del")
{
Employee employees = db.Employees.Find(Int32.Parse(id));
db.Employees.Remove(employees);
db.SaveChanges();
return RedirectToAction("Index");
}
}
catch (InvalidOperationException ex)
{
}
catch (Exception e)
{
}
}