public ActionResult Index(PersonAddressModel model) { var client = new PersonServiceClient(); var persons = client.GetPersons(2, model.City, model.Province, model.Country, model.Name).ToList(); model.Items = persons; return(View(model)); }
public ActionResult Index(string id) { var model = new PersonAddressModel(); if (!string.IsNullOrEmpty(id)) { var personID = int.Parse(id); if (personID > 0) { var client = new PersonServiceClient(); var addresses = client.GetAddressesByPersonID(personID).ToList(); model.Items = addresses; } } return(View(model)); }
/// <summary> /// FirstName, LastName and Email must have a value. Email must not exist already. /// </summary> /// <param name="newPerson"></param> private void CheckDataValidity(PersonAddressModel newPerson) { List <PersonAddressModel> savedPeople = _dataAccess.LoadData <PersonAddressModel>(SQLProceedures.LoadPeopleAddresses()); foreach (PersonAddressModel savedPerson in savedPeople) { if (newPerson.FirstName == "") { throw new Exception("First name is required"); } if (newPerson.LastName == "") { throw new Exception("Last name is required"); } if (savedPerson.Email == "" || savedPerson.Email == newPerson.Email) { throw new Exception("Email already exists", null); } } }
public void SavePerson(PersonAddressModel person) { CheckDataValidity(person); _dataAccess.SaveData(SQLProceedures.SavePersonAddress(), person); }