I have tried adding null
check and try catch blocks but I am not able to solve this issue.
Error : The DeleteConfirmed at VCSSource/Web/Controllers/EnvController.cs in line 180 may unintentionally allow setting the value of SaveChanges in DeleteConfirmed, in the object VCSSource/Web/Controllers/EnvController.cs at line 180
Code :
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public ActionResult DeleteConfirmed(int id)
{
if (id > 0) // fix for CheckMarx : Unsafe Object Binding
{
ENV eNV = db.ENVs.Find(id);
ENV eNV_del = db.ENVs.Remove(eNV);
try
{
if (eNV_del != null && eNV_del.ENV_NM.Length > 0) {
db.SaveChanges();
}
return RedirectToAction("Index");
}
catch (DataException ex)
{
throw ex;
}
}
else
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
}