public async Task <ActionResult> Create(ContactViewModel contactVm) { if (!ModelState.IsValid) { contactVm.PartnerNumberSelection = await GetPartnerSelection(); return(View(contactVm)); } _contactRepository.Add(contactVm.Map <Contact>()); await UnitOfWork.CompleteAsync(); return(RedirectToAction("List")); }
public async Task <ActionResult> Update(int id, ContactViewModel contactVm) { if (!ModelState.IsValid) { return(View(contactVm)); } var contactInDb = await _contactRepository.GetAsync(id); if (contactInDb == null) { return(View(contactVm)); } contactInDb = contactVm.Map <Contact>(); _contactRepository.Add(contactInDb); await UnitOfWork.CompleteAsync(); return(RedirectToAction("List")); }