public async Task <ActionResult> Create(ContactModel.Contact contact) { try { if (ModelState.IsValid) { var serviceContact = new Api.Service.Contact() { FirstName = contact.FirstName, LastName = contact.LastName, Email = contact.Email, PhoneNumber = Convert.ToInt64(contact.PhoneNumber), Status = Convert.ToInt32(contact.SelectedStatus) }; var response = await _service.CreateContact(ServiceConfiguration.serviceUrl, serviceContact); return(RedirectToAction(nameof(Index))); } return(View("Create", contact)); } catch { return(View("Create", contact)); } }
// GET: Contact/Edit/5 public async Task <ViewResult> Edit(int id) { var response = await _service.GetContacts(ServiceConfiguration.serviceUrl); var contact = response.Where(r => r.Id == id).FirstOrDefault(); var serviceContact = new ContactModel.Contact() { Id = id, FirstName = contact.FirstName, LastName = contact.LastName, Email = contact.Email, PhoneNumber = contact.PhoneNumber, SelectedStatus = Convert.ToString(contact.Status) }; return(View("Edit", serviceContact)); }