I need to set a value in a table for a subset of rows. In SQL, I would do this:
UPDATE dbo.Person SET is_default = 0 WHERE person_id = 5
Is
This worked best.
(from p in Context.person_account_portfolio
where p.person_id == personId select p).ToList()
.ForEach(x => x.is_default = false);
Context.SaveChanges();
public ActionResult OrderDel(int id)
{
string a = Session["UserSession"].ToString();
var s = (from test in ob.Order_Details where test.Email_ID_Fk == a && test.Order_ID == id select test).FirstOrDefault();
s.Status = "Order Cancel By User";
ob.SaveChanges();
//foreach(var updter in s)
//{
// updter.Status = "Order Cancel By User";
//}
return Json("Sucess", JsonRequestBehavior.AllowGet);
} <script>
function Cancel(id) {
if (confirm("Are your sure ? Want to Cancel?")) {
$.ajax({
type: 'POST',
url: '@Url.Action("OrderDel", "Home")/' + id,
datatype: 'JSON',
success: function (Result) {
if (Result == "Sucess")
{
alert("Your Order has been Canceled..");
window.location.reload();
}
},
error: function (Msgerror) {
alert(Msgerror.responseText);
}
})
}
}
</script>