How to insert before Check Data using MVC3

Jayakumars
Posted by Jayakumars under ASP.NET MVC category on | Points: 40 | Views : 2358
[HttpPost]
public ActionResult Create(FormCollection collection,ProductsHondaofConyer p)
{
try
{
var Tagid = collection["TagID"];
DataClasses1DataContext db = new DataClasses1DataContext();
var qry = (from c in db.ProductsHondaofConyers where c.TagID == Convert.ToInt32(Tagid) select c).Count();
if (qry !=1)
{
db.ProductsHondaofConyers.InsertOnSubmit(p);
db.SubmitChanges();
}
// TODO: Add insert logic here

return RedirectToAction("Index");
}
catch
{
return View();
}
}

Comments or Responses

Login to post response