public ActionResult Index(Person person)
		{
			if (!ModelState.IsValid)
			{
			    return View(GetEditModel(person));
			}
			PersonService.SavePerson(person);
			return View("ViewPerson", GetViewModel(person));
		}
		private PersonViewModel GetViewModel(Person person)
		{
			return new PersonViewModel
			{
				Person = person,
				EmployerName = person.EmployerId.HasValue 
					? CompanyService.GetCompany(person.EmployerId.Value).Name
					: null
			};
		}
 private PersonEditModel GetEditModel(Person person)
 {
     return new PersonEditModel
     {
         Person = person,
         Genders = new Dictionary<string, string> { { "M", "Male" }, { "F", "Female" } },
         Roles = new List<Role> { new Role(0, "Administrator"), new Role(1, "Developer"), new Role(2, "User") },
         Companies = new SelectList(CompanyService.GetCompanies(), "Id", "Name")
     };
 }
示例#4
0
 public static void SavePerson(Person person)
 {
     cachedPerson = person;
 }