Action method with Http post , authenticate and insert a student record in DB
[Authorize]
[HttpPost]
Public ActionResult InserStudent(Student student)
{
if(ModelState.IsValid)
{
using(var context=new StudentContext())
{
Var entity = new StudentTbl
{
Id=student.Id,
Name=student.Name
};
context.StudentTbl.Add(entity);
context.SaveChanges();
}
return RedirectToAction("Index");
}
Return View(student);
}
No comments:
Post a Comment