public void Add(PersonViewModel person) { Person Person = Mapper.Map<Person>(person); Person.user = null; repositoryPersonGeneral.Create(Person); //User user = repository.GetByID(Person.UserID); //user.people.Add(Person); //repository.Update(user); }
public void Delete(PersonViewModel person) { Person Person = repositoryPersonGeneral.GetByID(person.ID.ToString());//Mapper.Map<Person>(person); repositoryPersonGeneral.Delete(Person); }
public ActionResult AddAddress(PersonViewModel person, FormCollection collection) { string ss = collection[collection.Count - 4]; person.addresses[person.addresses.Count - 1].street.CityId = Convert.ToInt32(ss); service.Update(person); return RedirectToAction("Index"); }
public void Update(PersonViewModel person) { Person Person = Mapper.Map<Person>(person); User user = repository.GetByID(person.UserID); Person.user = user; if (person.addresses != null) { Person.addresses = new List<Address>(); foreach (var a in person.addresses) { Address address = Mapper.Map<Address>(a); // address.people = new List<Person>(); //// //address.people.Add(Person); if (address.ID == 0) { repositoryAddressGeneral.Create(address); } else { repositoryAddressGeneral.Update(address); } Person.addresses.Add(address); // } } if (person.phones != null) { Person.phoneNumbers = new List<PhoneNumber>(); foreach (var a in person.phones) { PhoneNumber pn = Mapper.Map<PhoneNumber>(a); pn.PersonID = person.ID; // pn.person = Person; if (pn.ID == 0) { repositoryPhoneNumberGeneral.Create(pn); } else { repositoryPhoneNumberGeneral.Update(pn); } Person.phoneNumbers.Add(pn); } } //User user = repository.GetByID(person.UserID); //user.people.Add(Person); //repository.Update(user); repositoryPersonGeneral.Create(Person);//.Update(Person); }
public ActionResult Edit(PersonViewModel person) { service.Update(person); return RedirectToAction("Index"); }
public ActionResult Delete(PersonViewModel person) { service.Delete(person); return RedirectToAction("Index"); }
public ActionResult AddPerson(PersonViewModel person) { service.Add(person); return RedirectToAction("Index"); }
public ActionResult AddPerson() { PersonViewModel person = new PersonViewModel(); person.UserID = User.Identity.GetUserId(); person.addresses = new List<AddressViewModel>(); person.phones = new List<PhoneNumberViewModel>(); return View(person); }
public ActionResult AddPN(PersonViewModel person) { PersonViewModel personNew = service.GetPersonBy(person.ID); personNew.phones.Add(person.phones[person.phones.Count - 1]); service.Update(personNew); return RedirectToAction("Index"); }