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; }
}
[HttpGet]
public ActionResult AddPerson()
{
return View();
}
[HttpPost]
public ActionResult AddPerson(Person person)
{
mDataContext.Persons.Add(person);
mDataContext.SaveChanges();
return RedirectToAction("Index");
}
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; }
}
[HttpPost]
public ActionResult AddPerson(Person person)
{
if (ModelState.IsValid)
{
mDataContext.Persons.Add(person);
mDataContext.SaveChanges();
RedirectToAction("Index");
}
return View();
}
Also in C#:
- visual studio c# mark class deprecated
- C# delegate
- unity c# is not equal to
- c# auto property set default value
- leantween sequence
- unity detect any key
- button commandfield commandargument pass textbox
- comment envoyer un socket C#
- c# copy file
- c# make string null
- prefab gets character transform
- c# skip following code in loop
- freeze rotation in code c#
- syntaxe switch c#
- go to next itiration in foreach C#
- unity fps counter
- to list c#
- unity rotation
- convert system.byte a string c#
- c# exit console
- asp.net core redirecttoaction with parameters
- display none asp.net
- .net core copy file in folder to root
- c# how to convert string to int