Answers for "MVC company assignments"

C#
0

MVC company assignments

[HttpPost]

public ActionResult AddPerson(Person person)

{

    if (ModelState.IsValid)

    {

        mDataContext.Persons.Add(person);

        mDataContext.SaveChanges();

        RedirectToAction("Index");

    }


    return View();

}
Posted by: Guest on June-17-2020
0

MVC company assignments

public class Person

{

    [Key]
    [Required]
    public int PersonId { get; set; }

    [Required]
    [Display(Name = "First Name")]
    public string FirstName { get; set; }

    [Required]
    [Display(Name = "Last Name")]
    public string LastName { get; set; }

    [Required]
    public string Address { get; set; }

    [Required]
    [EmailAddress]
    public string Email { get; set; }

    [Required]
    [Display(Name = "Phone Number")]

    public long PhoneNumber { get; set; }

}
Posted by: Guest on June-17-2020
0

MVC company assignments

public class Person

{

    public string FirstName { get; set; }

    public string LastName { get; set; }

    public string Address { get; set; }

    public string Email { get; set; }

    public long PhoneNumber { get; set; }

}
Posted by: Guest on June-17-2020
0

MVC company assignments

[HttpGet]

public ActionResult AddPerson()

{

    return View();

}

[HttpPost]

public ActionResult AddPerson(Person person)

{

        mDataContext.Persons.Add(person);

        mDataContext.SaveChanges();

        return RedirectToAction("Index");

}
Posted by: Guest on June-17-2020

C# Answers by Framework

Browse Popular Code Answers by Language