commercial application asp net mvc database code example

Example 1: MVC company assignments

[HttpGet]

public ActionResult AddPerson()

{

    return View();

}

[HttpPost]

public ActionResult AddPerson(Person person)

{

        mDataContext.Persons.Add(person);

        mDataContext.SaveChanges();

        return RedirectToAction("Index");

}

Example 2: MVC company assignments

[HttpPost]

public ActionResult AddPerson(Person person)

{

    if (ModelState.IsValid)

    {

        mDataContext.Persons.Add(person);

        mDataContext.SaveChanges();

        RedirectToAction("Index");

    }


    return View();

}