public ActionResult Edit(ContactInformationEditModel modelContactInformation) { ContactInformation myContactInformation = _contactInformationRepository.GetById(modelContactInformation.Id); myContactInformation.Type = modelContactInformation.Type; myContactInformation.Value = modelContactInformation.Value; ContactInformation contactInformation = _contactInformationRepository.Update(myContactInformation); const string title = "Contacto Actualizado"; _viewMessageLogic.SetNewMessage(title, "", ViewMessageType.InformationMessage); return(RedirectToAction("Details/" + contactInformation.People.Id, modelContactInformation.Controller)); }
public IActionResult Update([FromRoute] int id, [FromBody] ContactDetailDTO contactDetailDTO) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (contactDetailDTO.ContactDetailId.HasValue && id != contactDetailDTO.ContactDetailId.Value) { return(BadRequest(new { Message = "Missmatch in the contact detail id in request" })); } var contact = _contactInformationRepository.GetContactDetailById(id); if (contact == null) { return(BadRequest(new { Message = "Contact information not present for passed contact detail id" })); } Status status; contact.Email = contactDetailDTO.Email; contact.FirstName = contactDetailDTO.FirstName; contact.LastName = contactDetailDTO.LastName; contact.PhoneNumber = contactDetailDTO.PhoneNumber; Enum.TryParse <Status>(contactDetailDTO.Status, out status); contact.Status = status; _contactInformationRepository.Update(contact); return(Ok(new { Message = "Contact information updated successfully" })); } catch (Exception ex) { return(BadRequest(new { Message = ex.Message })); } }