private void Update(object sender, EventArgs e) { patient.FirstName = txtFirstName.Text; patient.LastName = txtLastName.Text; patient.Gender = txtGender.Text; patient.BirthDate = Convert.ToDateTime(dateTimePickerBirthDate.Value.Date); patient.Occupation = txtOccupation.Text; patient.Email = txtEmail.Text; patient.ContactNumber = txtContactNumber.Text; var address = addressManager.GetWithWhereCondition <Address>($"PatientId = {patient.Id}").FirstOrDefault(); address.PatientId = patient.Id; address.City = txtCity.Text; address.Province = txtProvince.Text; address.PostalCode = txtPostalCode.Text; var emergencyContact = emergencyContactManager.GetWithWhereCondition <EmergencyContact>($"PatientId = {patient.Id}").FirstOrDefault(); emergencyContact.PatientId = patient.Id; emergencyContact.FirstName = txtEcFirstname.Text; emergencyContact.LastName = txtECLastName.Text; emergencyContact.ContactNumber = txtECContactNum.Text; if (patientManager.Update(patient) && addressManager.Update(address) && emergencyContactManager.Update(emergencyContact)) { MessageBox.Show("Updated succesfully."); } }
public IHttpActionResult Update([FromBody] EmergencyContact emergencyContact) { try { return(Content(HttpStatusCode.OK, _emergencyContactManager.Update(emergencyContact))); } catch (Exception ex) { return(Content(HttpStatusCode.InternalServerError, ex.Message)); } }