private async Task SaveItemAsync() { Notification result = Notification.Success(); ModelUpdateEvent updateEvent = _isNewModel ? ModelUpdateEvent.Created : ModelUpdateEvent.Updated; result = _validator.ValidateModel(Model); if (result.IsValid()) { var saveResult = await _repository.SaveSampleItemAsync(Model, updateEvent); result.AddRange(saveResult); } if (result.IsValid()) { var eventMessenger = CC.IoC.Resolve <IEventAggregator>(); ModelUpdatedMessageResult <SampleItem> eventResult = new ModelUpdatedMessageResult <SampleItem>() { UpdatedModel = Model, UpdateEvent = updateEvent }; eventMessenger.GetEvent <ModelUpdatedMessageEvent <SampleItem> >().Publish(eventResult); await Close(); } else { await UserNotifier.ShowMessageAsync(result.ToString(), "Save Failed"); } }
private async void SaveItem() { Notification result = Notification.Success(); ModelUpdateEvent updateEvent = _isNewModel ? ModelUpdateEvent.Created : ModelUpdateEvent.Updated; //TODO: model validation var saveResult = await _repository.SaveItemAsync(Model, updateEvent); result.AddRange(saveResult); if (result.IsValid()) { ModelUpdatedMessageResult <TodoItem> eventResult = new ModelUpdatedMessageResult <TodoItem> { UpdatedModel = Model, UpdateEvent = updateEvent }; App.EventManager.GetEvent <ModelUpdatedMessageEvent <TodoItem> >().Publish(eventResult); await Navigation.GoBackAsync(); //NOTE: fails :( will work if INavigationService injected in constructor } else { //TODO: show user failure message //await UserNotifier.ShowMessageAsync(result.ToString(), "Save Failed"); } }