private async void ExecuteAction(string action) { try { PatronDto patron = null; MessageControl message = null; if (!action.Equals("Save")) { patron = await new Services.PatronServices().CreatePatron(GetPatronInfo()); message = MessageControl.SuccessfulRegistration(); } else { patron = await new Services.PatronServices().EditPatron(GetPatronInfo()); message = MessageControl.SuccessfulChanges(); } if (patron != null) { if (imageContainer.Tag != null && imageContainer.Tag.ToString().Equals("hasChanged")) { var result = await Services.FileServices.GetInstance().UploadFile(OpenFileDialog.FileName, patron); if (result == false) { new MessageControl("Error", "We had an error while trying to upload the image, please try again in a few minutes", MessageType.Error) .ShowMessage(); } else { message.ShowMessage(); MainWindow.DisplayScreen(new ShowPatrons()); } } else { message.ShowMessage(); MainWindow.DisplayScreen(new ShowPatrons()); } } else { MessageControl.RegistrationFailed().ShowMessage(); } } catch (Exception) { MessageControl.Error().ShowMessage(); } }